From d65ef60ea24a25e636f5a51b51192abbc883da12 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 24 Aug 2020 10:46:58 +0200 Subject: [PATCH] clang: Fix include/resource dir confusion The getClangResourceDirAndVersion() function in ClangTools could return the actual resource dir or the include dir, depending on the input. This mistake happened because of misleading names spread all around the code. Now the function returns what it says, and the other names are accurate as well. Change-Id: I0a8600857ee7b9fafb16256e0d1ad203ac3273d2 Reviewed-by: David Schulz --- qbs/modules/clang_defines/clang_defines.qbs | 4 +-- src/libs/clangsupport/CMakeLists.txt | 2 +- src/plugins/clangcodemodel/clangutils.cpp | 2 +- .../clangpchmanager/projectupdater.cpp | 2 +- .../clangtools/clangtoolruncontrol.cpp | 16 +++++------ src/plugins/clangtools/clangtoolruncontrol.h | 2 +- src/plugins/clangtools/executableinfo.cpp | 6 ++-- src/plugins/clangtools/executableinfo.h | 2 +- src/plugins/coreplugin/icore.cpp | 4 +-- src/plugins/coreplugin/icore.h | 2 +- .../cpptools/compileroptionsbuilder.cpp | 6 ++-- src/plugins/cpptools/compileroptionsbuilder.h | 7 ++--- src/plugins/cpptools/headerpathfilter.cpp | 11 ++++---- src/plugins/cpptools/headerpathfilter.h | 6 ++-- src/shared/clang/clang_defines.pri | 4 +-- .../unittest/compileroptionsbuilder-test.cpp | 18 ++++++------ tests/unit/unittest/creator_dependency.pri | 2 +- tests/unit/unittest/headerpathfilter-test.cpp | 28 +++++++++---------- tests/unit/unittest/projectupdater-test.cpp | 6 ++-- 19 files changed, 65 insertions(+), 65 deletions(-) diff --git a/qbs/modules/clang_defines/clang_defines.qbs b/qbs/modules/clang_defines/clang_defines.qbs index 361941c2c9c..21b32c45408 100644 --- a/qbs/modules/clang_defines/clang_defines.qbs +++ b/qbs/modules/clang_defines/clang_defines.qbs @@ -7,12 +7,12 @@ Module { cpp.defines: libclang.present ? [ 'CLANG_VERSION="' + libclang.llvmVersion + '"', - 'CLANG_RESOURCE_DIR="' + FileInfo.joinPaths(libclang.llvmLibDir, "clang", + 'CLANG_INCLUDE_DIR="' + FileInfo.joinPaths(libclang.llvmLibDir, "clang", libclang.llvmVersion, "include") + '"', 'CLANG_BINDIR="' + libclang.llvmBinDir + '"', ] : [ 'CLANG_VERSION=""', - 'CLANG_RESOURCE_DIR=""', + 'CLANG_INCLUDE_DIR=""', 'CLANG_BINDIR=""', ] } diff --git a/src/libs/clangsupport/CMakeLists.txt b/src/libs/clangsupport/CMakeLists.txt index d1f38507cb9..7117066ac17 100644 --- a/src/libs/clangsupport/CMakeLists.txt +++ b/src/libs/clangsupport/CMakeLists.txt @@ -5,7 +5,7 @@ add_qtc_library(ClangSupport PUBLIC_DEPENDS Utils Sqlite Qt5::Core Qt5::Network PUBLIC_DEFINES CLANG_VERSION="${CLANG_VERSION}" - CLANG_RESOURCE_DIR="${IDE_LIBEXEC_PATH}/clang/lib/clang/${CLANG_VERSION}/include" + CLANG_INCLUDE_DIR="${IDE_LIBEXEC_PATH}/clang/lib/clang/${CLANG_VERSION}/include" CLANG_BINDIR="${IDE_LIBEXEC_PATH}/clang/bin" DEFINES CLANGSUPPORT_BUILD_LIB PUBLIC_INCLUDES diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp index 621900c83e4..57f0170faab 100644 --- a/src/plugins/clangcodemodel/clangutils.cpp +++ b/src/plugins/clangcodemodel/clangutils.cpp @@ -75,7 +75,7 @@ public: UseLanguageDefines::No, useBuildSystemWarnings, QString(CLANG_VERSION), - QString(CLANG_RESOURCE_DIR)) + QString(CLANG_INCLUDE_DIR)) { } diff --git a/src/plugins/clangpchmanager/projectupdater.cpp b/src/plugins/clangpchmanager/projectupdater.cpp index e006357e0c5..8c021fc3e55 100644 --- a/src/plugins/clangpchmanager/projectupdater.cpp +++ b/src/plugins/clangpchmanager/projectupdater.cpp @@ -332,7 +332,7 @@ ProjectUpdater::SystemAndProjectIncludeSearchPaths ProjectUpdater::createInclude CppTools::HeaderPathFilter filter(projectPart, CppTools::UseTweakedHeaderPaths::Yes, CLANG_VERSION, - CLANG_RESOURCE_DIR, + CLANG_INCLUDE_DIR, projectDirectory(projectPart.project), buildDirectory(projectPart.project)); filter.process(); diff --git a/src/plugins/clangtools/clangtoolruncontrol.cpp b/src/plugins/clangtools/clangtoolruncontrol.cpp index 090e9d82162..ac054135dec 100644 --- a/src/plugins/clangtools/clangtoolruncontrol.cpp +++ b/src/plugins/clangtools/clangtoolruncontrol.cpp @@ -154,7 +154,7 @@ private: bool m_success = false; }; -static AnalyzeUnits toAnalyzeUnits(const FileInfos &fileInfos, const FilePath &clangResourceDir, +static AnalyzeUnits toAnalyzeUnits(const FileInfos &fileInfos, const FilePath &clangIncludeDir, const QString &clangVersion) { AnalyzeUnits unitsToAnalyze; @@ -166,7 +166,7 @@ static AnalyzeUnits toAnalyzeUnits(const FileInfos &fileInfos, const FilePath &c UseLanguageDefines::No, UseBuildSystemWarnings::No, clangVersion, - clangResourceDir.toString()); + clangIncludeDir.toString()); QStringList arguments = extraClangToolsPrependOptions(); arguments.append(optionsBuilder.build(fileInfo.kind, usePrecompiledHeaders)); arguments.append(extraClangToolsAppendOptions()); @@ -176,12 +176,12 @@ static AnalyzeUnits toAnalyzeUnits(const FileInfos &fileInfos, const FilePath &c return unitsToAnalyze; } -AnalyzeUnits ClangToolRunWorker::unitsToAnalyze(const FilePath &clangResourceDir, +AnalyzeUnits ClangToolRunWorker::unitsToAnalyze(const FilePath &clangIncludeDir, const QString &clangVersion) { QTC_ASSERT(m_projectInfo.isValid(), return AnalyzeUnits()); - return toAnalyzeUnits(m_fileInfos, clangResourceDir, clangVersion); + return toAnalyzeUnits(m_fileInfos, clangIncludeDir, clangVersion); } static QDebug operator<<(QDebug debug, const Utils::Environment &environment) @@ -288,10 +288,10 @@ void ClangToolRunWorker::start() Utils::NormalMessageFormat); // Collect files - const auto clangResourceDirAndVersion = - getClangResourceDirAndVersion(runControl()->runnable().executable); - const AnalyzeUnits unitsToProcess = unitsToAnalyze(clangResourceDirAndVersion.first, - clangResourceDirAndVersion.second); + const auto clangIncludeDirAndVersion = + getClangIncludeDirAndVersion(runControl()->runnable().executable); + const AnalyzeUnits unitsToProcess = unitsToAnalyze(clangIncludeDirAndVersion.first, + clangIncludeDirAndVersion.second); qCDebug(LOG) << "Files to process:" << unitsToProcess; m_queue.clear(); diff --git a/src/plugins/clangtools/clangtoolruncontrol.h b/src/plugins/clangtools/clangtoolruncontrol.h index 97f667a01ac..e72df21c680 100644 --- a/src/plugins/clangtools/clangtoolruncontrol.h +++ b/src/plugins/clangtools/clangtoolruncontrol.h @@ -93,7 +93,7 @@ private: QList runnerCreators(); template ClangToolRunner *createRunner(); - AnalyzeUnits unitsToAnalyze(const Utils::FilePath &clangResourceDir, + AnalyzeUnits unitsToAnalyze(const Utils::FilePath &clangIncludeDir, const QString &clangVersion); void analyzeNextFile(); diff --git a/src/plugins/clangtools/executableinfo.cpp b/src/plugins/clangtools/executableinfo.cpp index 6e7bb1fcd4f..d8ab050c20c 100644 --- a/src/plugins/clangtools/executableinfo.cpp +++ b/src/plugins/clangtools/executableinfo.cpp @@ -203,13 +203,13 @@ static QString queryVersion(const FilePath &clangToolPath) return {}; } -QPair getClangResourceDirAndVersion(const FilePath &clangToolPath) +QPair getClangIncludeDirAndVersion(const FilePath &clangToolPath) { const FilePath dynamicResourceDir = queryResourceDir(clangToolPath); const QString dynamicVersion = queryVersion(clangToolPath); if (dynamicResourceDir.isEmpty() || dynamicVersion.isEmpty()) - return qMakePair(FilePath::fromString(CLANG_RESOURCE_DIR), QString(CLANG_VERSION)); - return qMakePair(dynamicResourceDir, dynamicVersion); + return qMakePair(FilePath::fromString(CLANG_INCLUDE_DIR), QString(CLANG_VERSION)); + return qMakePair(dynamicResourceDir + "/include", dynamicVersion); } } // namespace Internal diff --git a/src/plugins/clangtools/executableinfo.h b/src/plugins/clangtools/executableinfo.h index 95e61df4566..aa297dcb5ef 100644 --- a/src/plugins/clangtools/executableinfo.h +++ b/src/plugins/clangtools/executableinfo.h @@ -34,7 +34,7 @@ namespace ClangTools { namespace Internal { -QPair getClangResourceDirAndVersion(const Utils::FilePath &clangToolPath); +QPair getClangIncludeDirAndVersion(const Utils::FilePath &clangToolPath); class ClangTidyInfo { diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index c048b9f641f..904bba89136 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -491,11 +491,11 @@ static QString clangIncludePath(const QString &clangVersion) \internal */ QString ICore::clangIncludeDirectory(const QString &clangVersion, - const QString &clangResourceDirectory) + const QString &clangFallbackIncludeDir) { QDir dir(libexecPath() + "/clang" + clangIncludePath(clangVersion)); if (!dir.exists() || !QFileInfo(dir, "stdint.h").exists()) - dir = QDir(clangResourceDirectory); + dir = QDir(clangFallbackIncludeDir); return QDir::toNativeSeparators(dir.canonicalPath()); } diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index 119c9035bc7..3b012018c6d 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -161,7 +161,7 @@ public: static QString clangTidyExecutable(const QString &clangBinDirectory); static QString clazyStandaloneExecutable(const QString &clangBinDirectory); static QString clangIncludeDirectory(const QString &clangVersion, - const QString &clangResourceDirectory); + const QString &clangFallbackIncludeDir); static QString buildCompatibilityString(); static QStatusBar *statusBar(); diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp index 935a12f5286..c990c276650 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder.cpp @@ -105,14 +105,14 @@ CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart, UseLanguageDefines useLanguageDefines, UseBuildSystemWarnings useBuildSystemWarnings, const QString &clangVersion, - const QString &clangResourceDirectory) + const QString &clangIncludeDirectory) : m_projectPart(projectPart) , m_useSystemHeader(useSystemHeader) , m_useTweakedHeaderPaths(useTweakedHeaderPaths) , m_useLanguageDefines(useLanguageDefines) , m_useBuildSystemWarnings(useBuildSystemWarnings) , m_clangVersion(clangVersion) - , m_clangResourceDirectory(clangResourceDirectory) + , m_clangIncludeDirectory(clangIncludeDirectory) { } @@ -332,7 +332,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions() HeaderPathFilter filter{m_projectPart, m_useTweakedHeaderPaths, m_clangVersion, - m_clangResourceDirectory}; + m_clangIncludeDirectory}; filter.process(); diff --git a/src/plugins/cpptools/compileroptionsbuilder.h b/src/plugins/cpptools/compileroptionsbuilder.h index ee7e3733129..cfaeecdea82 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.h +++ b/src/plugins/cpptools/compileroptionsbuilder.h @@ -45,14 +45,13 @@ CPPTOOLS_EXPORT QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, class CPPTOOLS_EXPORT CompilerOptionsBuilder { public: - CompilerOptionsBuilder( - const ProjectPart &projectPart, + CompilerOptionsBuilder(const ProjectPart &projectPart, UseSystemHeader useSystemHeader = UseSystemHeader::No, UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::No, UseLanguageDefines useLanguageDefines = UseLanguageDefines::No, UseBuildSystemWarnings useBuildSystemWarnings = UseBuildSystemWarnings::No, const QString &clangVersion = QString(), - const QString &clangResourceDirectory = QString()); + const QString &clangIncludeDirectory = QString()); QStringList build(ProjectFile::Kind fileKind, UsePrecompiledHeaders usePrecompiledHeaders); QStringList options() const { return m_options; } @@ -112,7 +111,7 @@ private: const UseBuildSystemWarnings m_useBuildSystemWarnings; const QString m_clangVersion; - const QString m_clangResourceDirectory; + const QString m_clangIncludeDirectory; struct { QStringList flags; diff --git a/src/plugins/cpptools/headerpathfilter.cpp b/src/plugins/cpptools/headerpathfilter.cpp index 5268511b528..c0a1c04cf9d 100644 --- a/src/plugins/cpptools/headerpathfilter.cpp +++ b/src/plugins/cpptools/headerpathfilter.cpp @@ -104,14 +104,14 @@ void HeaderPathFilter::filterHeaderPath(const ProjectExplorer::HeaderPath &heade namespace { -QString clangIncludeDirectory(const QString &clangVersion, const QString &clangResourceDirectory) +QString clangIncludeDirectory(const QString &clangVersion, const QString &clangFallbackIncludeDir) { #ifndef UNIT_TESTS - return Core::ICore::clangIncludeDirectory(clangVersion, clangResourceDirectory); + return Core::ICore::clangIncludeDirectory(clangVersion, clangFallbackIncludeDir); #else Q_UNUSED(clangVersion) - Q_UNUSED(clangResourceDirectory) - return {CLANG_RESOURCE_DIR}; + Q_UNUSED(clangFallbackIncludeDir) + return {CLANG_INCLUDE_DIR}; #endif } @@ -158,7 +158,8 @@ void HeaderPathFilter::tweakHeaderPaths() auto split = resourceIterator(builtInHeaderPaths); if (!clangVersion.isEmpty()) { - const QString clangIncludePath = clangIncludeDirectory(clangVersion, clangResourceDirectory); + const QString clangIncludePath + = clangIncludeDirectory(clangVersion, clangFallbackIncludeDirectory); builtInHeaderPaths.insert(split, HeaderPath{clangIncludePath, HeaderPathType::BuiltIn}); } } diff --git a/src/plugins/cpptools/headerpathfilter.h b/src/plugins/cpptools/headerpathfilter.h index b1a22b098a6..4482c230ae4 100644 --- a/src/plugins/cpptools/headerpathfilter.h +++ b/src/plugins/cpptools/headerpathfilter.h @@ -35,12 +35,12 @@ public: HeaderPathFilter(const ProjectPart &projectPart, UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::Yes, const QString &clangVersion = {}, - const QString &clangResourceDirectory = {}, + const QString &clangIncludeDirectory = {}, const QString &projectDirectory = {}, const QString &buildDirectory = {}) : projectPart{projectPart} , clangVersion{clangVersion} - , clangResourceDirectory{clangResourceDirectory} + , clangFallbackIncludeDirectory{clangIncludeDirectory} , projectDirectory(ensurePathWithSlashEnding(projectDirectory)) , buildDirectory(ensurePathWithSlashEnding(buildDirectory)) , useTweakedHeaderPaths{useTweakedHeaderPaths} @@ -67,7 +67,7 @@ public: ProjectExplorer::HeaderPaths userHeaderPaths; const ProjectPart &projectPart; const QString clangVersion; - const QString clangResourceDirectory; + const QString clangFallbackIncludeDirectory; const QString projectDirectory; const QString buildDirectory; const UseTweakedHeaderPaths useTweakedHeaderPaths; diff --git a/src/shared/clang/clang_defines.pri b/src/shared/clang/clang_defines.pri index 4453c8ba6de..54e35433b8e 100644 --- a/src/shared/clang/clang_defines.pri +++ b/src/shared/clang/clang_defines.pri @@ -1,5 +1,5 @@ DEFINES += CLANG_VERSION=\\\"$${LLVM_VERSION}\\\" -CLANG_RESOURCE_DIR=$$clean_path($${LLVM_LIBDIR}/clang/$${LLVM_VERSION}/include) -DEFINES += "\"CLANG_RESOURCE_DIR=\\\"$${CLANG_RESOURCE_DIR}\\\"\"" +CLANG_INCLUDE_DIR=$$clean_path($${LLVM_LIBDIR}/clang/$${LLVM_VERSION}/include) +DEFINES += "\"CLANG_INCLUDE_DIR=\\\"$${CLANG_INCLUDE_DIR}\\\"\"" CLANG_BINDIR=$$clean_path($${LLVM_BINDIR}) DEFINES += "\"CLANG_BINDIR=\\\"$${CLANG_BINDIR}\\\"\"" diff --git a/tests/unit/unittest/compileroptionsbuilder-test.cpp b/tests/unit/unittest/compileroptionsbuilder-test.cpp index 76fe2be0662..100298b9ef6 100644 --- a/tests/unit/unittest/compileroptionsbuilder-test.cpp +++ b/tests/unit/unittest/compileroptionsbuilder-test.cpp @@ -208,7 +208,7 @@ TEST_F(CompilerOptionsBuilder, HeaderPathOptionsOrder) "-nostdinc++", "-I", toNative("/tmp/path"), "-I", toNative("/tmp/system_path"), - "-isystem", toNative(CLANG_RESOURCE_DIR ""), + "-isystem", toNative(CLANG_INCLUDE_DIR ""), "-isystem", toNative("/tmp/builtin_path"))); } @@ -232,7 +232,7 @@ TEST_F(CompilerOptionsBuilder, HeaderPathOptionsOrderCl) "-I", toNative("/tmp/path"), "-I", toNative("/tmp/system_path"), "/clang:-isystem", - "/clang:" + toNative(CLANG_RESOURCE_DIR ""), + "/clang:" + toNative(CLANG_INCLUDE_DIR ""), "/clang:-isystem", "/clang:" + toNative("/tmp/builtin_path"))); } @@ -254,7 +254,7 @@ TEST_F(CompilerOptionsBuilder, UseSystemHeader) "-nostdinc++", "-I", toNative("/tmp/path"), "-isystem", toNative("/tmp/system_path"), - "-isystem", toNative(CLANG_RESOURCE_DIR ""), + "-isystem", toNative(CLANG_INCLUDE_DIR ""), "-isystem", toNative("/tmp/builtin_path"))); } @@ -297,7 +297,7 @@ TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderMacOs) "-isystem", toNative("/usr/include/c++/4.2.1"), "-isystem", toNative("/usr/include/c++/4.2.1/backward"), "-isystem", toNative("/usr/local/include"), - "-isystem", toNative(CLANG_RESOURCE_DIR ""), + "-isystem", toNative(CLANG_INCLUDE_DIR ""), "-isystem", toNative("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"), "-isystem", toNative("/usr/include"), "-isystem", toNative("/tmp/builtin_path"))); @@ -334,7 +334,7 @@ TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderLinux) "-isystem", toNative("/usr/include/c++/4.8/backward"), "-isystem", toNative("/usr/include/x86_64-linux-gnu/c++/4.8"), "-isystem", toNative("/usr/local/include"), - "-isystem", toNative(CLANG_RESOURCE_DIR ""), + "-isystem", toNative(CLANG_INCLUDE_DIR ""), "-isystem", toNative("/usr/lib/gcc/x86_64-linux-gnu/4.8/include"), "-isystem", toNative("/usr/include/x86_64-linux-gnu"), "-isystem", toNative("/usr/include"))); @@ -366,7 +366,7 @@ TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderNoVersion) "-isystem", toNative("C:/mingw530/i686-w64-mingw32/include/c++"), "-isystem", toNative("C:/mingw530/i686-w64-mingw32/include/c++/i686-w64-mingw32"), "-isystem", toNative("C:/mingw530/i686-w64-mingw32/include/c++/backward"), - "-isystem", toNative(CLANG_RESOURCE_DIR ""), + "-isystem", toNative(CLANG_INCLUDE_DIR ""), "-isystem", toNative("C:/mingw530/i686-w64-mingw32/include"))); } @@ -395,7 +395,7 @@ TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderAndroidClang) "-nostdinc++", "-isystem", toNative("C:/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include"), "-isystem", toNative("C:/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++abi/include"), - "-isystem", toNative(CLANG_RESOURCE_DIR ""), + "-isystem", toNative(CLANG_INCLUDE_DIR ""), "-isystem", toNative("C:/Android/sdk/ndk-bundle/sysroot/usr/include/i686-linux-android"), "-isystem", toNative("C:/Android/sdk/ndk-bundle/sources/android/support/include"), "-isystem", toNative("C:/Android/sdk/ndk-bundle/sysroot/usr/include"))); @@ -657,7 +657,7 @@ TEST_F(CompilerOptionsBuilder, BuildAllOptions) "-I", IsPartOfHeader(toNative("wrappedQtHeaders/QtCore").toStdString()), "-I", toNative("/tmp/path"), "-I", toNative("/tmp/system_path"), - "-isystem", toNative(CLANG_RESOURCE_DIR ""), + "-isystem", toNative(CLANG_INCLUDE_DIR ""), "-isystem", toNative("/tmp/builtin_path"))); } @@ -695,7 +695,7 @@ TEST_F(CompilerOptionsBuilder, BuildAllOptionsCl) "-I", toNative("/tmp/path"), "-I", toNative("/tmp/system_path"), "/clang:-isystem", - "/clang:" + toNative(CLANG_RESOURCE_DIR ""), + "/clang:" + toNative(CLANG_INCLUDE_DIR ""), "/clang:-isystem", "/clang:" + toNative("/tmp/builtin_path"))); } diff --git a/tests/unit/unittest/creator_dependency.pri b/tests/unit/unittest/creator_dependency.pri index ef00624b957..84d1f181845 100644 --- a/tests/unit/unittest/creator_dependency.pri +++ b/tests/unit/unittest/creator_dependency.pri @@ -26,7 +26,7 @@ include($$PWD/../../../src/plugins/clangcodemodel/clangcodemodelunittestfiles.pr !isEmpty(CLANGFORMAT_LIBS): include($$PWD/../../../src/plugins/clangformat/clangformat-source.pri) } else { DEFINES += CLANG_VERSION=\\\"6.0.0\\\" -DEFINES += "\"CLANG_RESOURCE_DIR=\\\"/usr/include\\\"\"" +DEFINES += "\"CLANG_INCLUDE_DIR=\\\"/usr/include\\\"\"" } INCLUDEPATH += \ diff --git a/tests/unit/unittest/headerpathfilter-test.cpp b/tests/unit/unittest/headerpathfilter-test.cpp index b5589e8ec35..36ac8ad8800 100644 --- a/tests/unit/unittest/headerpathfilter-test.cpp +++ b/tests/unit/unittest/headerpathfilter-test.cpp @@ -162,12 +162,12 @@ TEST_F(HeaderPathFilter, ClangHeadersPath) CppTools::HeaderPathFilter filter{projectPart, CppTools::UseTweakedHeaderPaths::Yes, "6.0", - CLANG_RESOURCE_DIR}; + CLANG_INCLUDE_DIR}; filter.process(); ASSERT_THAT(filter.builtInHeaderPaths, - ElementsAre(HasBuiltIn(CLANG_RESOURCE_DIR), HasBuiltIn("/builtin_path"))); + ElementsAre(HasBuiltIn(CLANG_INCLUDE_DIR), HasBuiltIn("/builtin_path"))); } TEST_F(HeaderPathFilter, ClangHeadersPathWitoutClangVersion) @@ -198,7 +198,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderMacOs) CppTools::HeaderPathFilter filter{projectPart, CppTools::UseTweakedHeaderPaths::Yes, "6.0", - CLANG_RESOURCE_DIR}; + CLANG_INCLUDE_DIR}; filter.process(); @@ -206,7 +206,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderMacOs) ElementsAre(HasBuiltIn("/usr/include/c++/4.2.1"), HasBuiltIn("/usr/include/c++/4.2.1/backward"), HasBuiltIn("/usr/local/include"), - HasBuiltIn(CLANG_RESOURCE_DIR), + HasBuiltIn(CLANG_INCLUDE_DIR), HasBuiltIn("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"), HasBuiltIn("/usr/include"), HasBuiltIn("/builtin_path"))); @@ -229,7 +229,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderLinux) CppTools::HeaderPathFilter filter{projectPart, CppTools::UseTweakedHeaderPaths::Yes, "6.0", - CLANG_RESOURCE_DIR}; + CLANG_INCLUDE_DIR}; filter.process(); @@ -238,7 +238,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderLinux) HasBuiltIn("/usr/include/c++/4.8/backward"), HasBuiltIn("/usr/include/x86_64-linux-gnu/c++/4.8"), HasBuiltIn("/usr/local/include"), - HasBuiltIn(CLANG_RESOURCE_DIR), + HasBuiltIn(CLANG_INCLUDE_DIR), HasBuiltIn("/usr/lib/gcc/x86_64-linux-gnu/4.8/include"), HasBuiltIn("/usr/include/x86_64-linux-gnu"), HasBuiltIn("/usr/include"), @@ -258,11 +258,11 @@ TEST_F(HeaderPathFilter, RemoveGccInternalPaths) CppTools::HeaderPathFilter filter{projectPart, CppTools::UseTweakedHeaderPaths::Yes, "6.0", - CLANG_RESOURCE_DIR}; + CLANG_INCLUDE_DIR}; filter.process(); - ASSERT_THAT(filter.builtInHeaderPaths, ElementsAre(HasBuiltIn(CLANG_RESOURCE_DIR))); + ASSERT_THAT(filter.builtInHeaderPaths, ElementsAre(HasBuiltIn(CLANG_INCLUDE_DIR))); } // Some distributions ship the standard library headers in "/include/c++" (MinGW) @@ -280,12 +280,12 @@ TEST_F(HeaderPathFilter, RemoveGccInternalPathsExceptForStandardPaths) }; auto expected = projectPart.headerPaths; - expected << builtIn(CLANG_RESOURCE_DIR); + expected << builtIn(CLANG_INCLUDE_DIR); CppTools::HeaderPathFilter filter{projectPart, CppTools::UseTweakedHeaderPaths::Yes, "6.0", - CLANG_RESOURCE_DIR}; + CLANG_INCLUDE_DIR}; filter.process(); @@ -304,7 +304,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderNoVersion) CppTools::HeaderPathFilter filter{projectPart, CppTools::UseTweakedHeaderPaths::Yes, "6.0", - CLANG_RESOURCE_DIR}; + CLANG_INCLUDE_DIR}; filter.process(); @@ -313,7 +313,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderNoVersion) ElementsAre(HasBuiltIn("C:/mingw/i686-w64-mingw32/include/c++"), HasBuiltIn("C:/mingw/i686-w64-mingw32/include/c++/i686-w64-mingw32"), HasBuiltIn("C:/mingw/i686-w64-mingw32/include/c++/backward"), - HasBuiltIn(CLANG_RESOURCE_DIR), + HasBuiltIn(CLANG_INCLUDE_DIR), HasBuiltIn("C:/mingw/i686-w64-mingw32/include"))); } @@ -330,7 +330,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderAndroidClang) CppTools::HeaderPathFilter filter{projectPart, CppTools::UseTweakedHeaderPaths::Yes, "6.0", - CLANG_RESOURCE_DIR}; + CLANG_INCLUDE_DIR}; filter.process(); @@ -338,7 +338,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderAndroidClang) filter.builtInHeaderPaths, ElementsAre(HasBuiltIn("C:/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include"), HasBuiltIn("C:/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++abi/include"), - HasBuiltIn(CLANG_RESOURCE_DIR), + HasBuiltIn(CLANG_INCLUDE_DIR), HasBuiltIn("C:/Android/sdk/ndk-bundle/sysroot/usr/include/i686-linux-android"), HasBuiltIn("C:/Android/sdk/ndk-bundle/sources/android/support/include"), HasBuiltIn("C:/Android/sdk/ndk-bundle/sysroot/usr/include"))); diff --git a/tests/unit/unittest/projectupdater-test.cpp b/tests/unit/unittest/projectupdater-test.cpp index 52e68b308cf..536aa3044dc 100644 --- a/tests/unit/unittest/projectupdater-test.cpp +++ b/tests/unit/unittest/projectupdater-test.cpp @@ -125,7 +125,7 @@ protected: arguments.clone(), Utils::clone(compilerMacros), {{"project/.pre_includes", 1, ClangBackEnd::IncludeSearchPathType::System}, - {CLANG_RESOURCE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}}, + {CLANG_INCLUDE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}}, {}, {filePathId(headerPaths[1])}, {filePathIds(sourcePaths)}, @@ -136,7 +136,7 @@ protected: arguments2.clone(), Utils::clone(compilerMacros), {{"project/.pre_includes", 1, ClangBackEnd::IncludeSearchPathType::System}, - {CLANG_RESOURCE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}}, + {CLANG_INCLUDE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}}, {}, {filePathId(headerPaths[1])}, {filePathIds(sourcePaths)}, @@ -386,7 +386,7 @@ TEST_F(ProjectUpdater, CreateSortedIncludeSearchPaths) Eq(IncludeSearchPath{builtInPath.path, 5, IncludeSearchPathType::BuiltIn}), Eq(IncludeSearchPath{frameworkPath.path, 3, IncludeSearchPathType::Framework}), Eq(IncludeSearchPath{"project/.pre_includes", 1, IncludeSearchPathType::System}), - Eq(IncludeSearchPath{CLANG_RESOURCE_DIR, + Eq(IncludeSearchPath{CLANG_INCLUDE_DIR, 4, ClangBackEnd::IncludeSearchPathType::BuiltIn}))); ASSERT_THAT(paths.project,