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 {};