From 628babb5cb2c9170946b9f0de6c16005f7e39fa7 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 28 Feb 2023 14:04:54 +0100 Subject: [PATCH] CppEditor: Adapt to new LLVM directory layout Since https://reviews.llvm.org/D125860, the path contains only the major version. We try both variants anyway, as we cannot be sure all Linux distributions will adopt this scheme. Change-Id: I0bc7b0cf38d7cb4af61342477a6a1f0679095d30 Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/cppeditor/cppcodemodelsettings.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/cppeditor/cppcodemodelsettings.cpp b/src/plugins/cppeditor/cppcodemodelsettings.cpp index e4b567b7326..e0873427f79 100644 --- a/src/plugins/cppeditor/cppcodemodelsettings.cpp +++ b/src/plugins/cppeditor/cppcodemodelsettings.cpp @@ -363,11 +363,15 @@ static FilePath getClangHeadersPath(const FilePath &clangdFilePath) const QVersionNumber version = Utils::clangdVersion(clangdFilePath); QTC_ASSERT(!version.isNull(), return {}); static const QStringList libDirs{"lib", "lib64"}; + const QStringList versionStrings{QString::number(version.majorVersion()), version.toString()}; for (const QString &libDir : libDirs) { - const FilePath includePath = clangdFilePath.absolutePath().parentDir().pathAppended(libDir) - .pathAppended("clang").pathAppended(version.toString()).pathAppended("include"); - if (includePath.exists()) - return includePath; + for (const QString &versionString : versionStrings) { + const FilePath includePath = clangdFilePath.absolutePath().parentDir() + .pathAppended(libDir).pathAppended("clang") + .pathAppended(versionString).pathAppended("include"); + if (includePath.exists()) + return includePath; + } } QTC_CHECK(false); return {};