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 <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2020-08-24 10:46:58 +02:00
parent 643c9405bd
commit d65ef60ea2
19 changed files with 65 additions and 65 deletions

View File

@@ -7,12 +7,12 @@ Module {
cpp.defines: libclang.present ? [ cpp.defines: libclang.present ? [
'CLANG_VERSION="' + libclang.llvmVersion + '"', 'CLANG_VERSION="' + libclang.llvmVersion + '"',
'CLANG_RESOURCE_DIR="' + FileInfo.joinPaths(libclang.llvmLibDir, "clang", 'CLANG_INCLUDE_DIR="' + FileInfo.joinPaths(libclang.llvmLibDir, "clang",
libclang.llvmVersion, "include") + '"', libclang.llvmVersion, "include") + '"',
'CLANG_BINDIR="' + libclang.llvmBinDir + '"', 'CLANG_BINDIR="' + libclang.llvmBinDir + '"',
] : [ ] : [
'CLANG_VERSION=""', 'CLANG_VERSION=""',
'CLANG_RESOURCE_DIR=""', 'CLANG_INCLUDE_DIR=""',
'CLANG_BINDIR=""', 'CLANG_BINDIR=""',
] ]
} }

View File

@@ -5,7 +5,7 @@ add_qtc_library(ClangSupport
PUBLIC_DEPENDS Utils Sqlite Qt5::Core Qt5::Network PUBLIC_DEPENDS Utils Sqlite Qt5::Core Qt5::Network
PUBLIC_DEFINES PUBLIC_DEFINES
CLANG_VERSION="${CLANG_VERSION}" 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" CLANG_BINDIR="${IDE_LIBEXEC_PATH}/clang/bin"
DEFINES CLANGSUPPORT_BUILD_LIB DEFINES CLANGSUPPORT_BUILD_LIB
PUBLIC_INCLUDES PUBLIC_INCLUDES

View File

@@ -75,7 +75,7 @@ public:
UseLanguageDefines::No, UseLanguageDefines::No,
useBuildSystemWarnings, useBuildSystemWarnings,
QString(CLANG_VERSION), QString(CLANG_VERSION),
QString(CLANG_RESOURCE_DIR)) QString(CLANG_INCLUDE_DIR))
{ {
} }

View File

@@ -332,7 +332,7 @@ ProjectUpdater::SystemAndProjectIncludeSearchPaths ProjectUpdater::createInclude
CppTools::HeaderPathFilter filter(projectPart, CppTools::HeaderPathFilter filter(projectPart,
CppTools::UseTweakedHeaderPaths::Yes, CppTools::UseTweakedHeaderPaths::Yes,
CLANG_VERSION, CLANG_VERSION,
CLANG_RESOURCE_DIR, CLANG_INCLUDE_DIR,
projectDirectory(projectPart.project), projectDirectory(projectPart.project),
buildDirectory(projectPart.project)); buildDirectory(projectPart.project));
filter.process(); filter.process();

View File

@@ -154,7 +154,7 @@ private:
bool m_success = false; 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) const QString &clangVersion)
{ {
AnalyzeUnits unitsToAnalyze; AnalyzeUnits unitsToAnalyze;
@@ -166,7 +166,7 @@ static AnalyzeUnits toAnalyzeUnits(const FileInfos &fileInfos, const FilePath &c
UseLanguageDefines::No, UseLanguageDefines::No,
UseBuildSystemWarnings::No, UseBuildSystemWarnings::No,
clangVersion, clangVersion,
clangResourceDir.toString()); clangIncludeDir.toString());
QStringList arguments = extraClangToolsPrependOptions(); QStringList arguments = extraClangToolsPrependOptions();
arguments.append(optionsBuilder.build(fileInfo.kind, usePrecompiledHeaders)); arguments.append(optionsBuilder.build(fileInfo.kind, usePrecompiledHeaders));
arguments.append(extraClangToolsAppendOptions()); arguments.append(extraClangToolsAppendOptions());
@@ -176,12 +176,12 @@ static AnalyzeUnits toAnalyzeUnits(const FileInfos &fileInfos, const FilePath &c
return unitsToAnalyze; return unitsToAnalyze;
} }
AnalyzeUnits ClangToolRunWorker::unitsToAnalyze(const FilePath &clangResourceDir, AnalyzeUnits ClangToolRunWorker::unitsToAnalyze(const FilePath &clangIncludeDir,
const QString &clangVersion) const QString &clangVersion)
{ {
QTC_ASSERT(m_projectInfo.isValid(), return AnalyzeUnits()); 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) static QDebug operator<<(QDebug debug, const Utils::Environment &environment)
@@ -288,10 +288,10 @@ void ClangToolRunWorker::start()
Utils::NormalMessageFormat); Utils::NormalMessageFormat);
// Collect files // Collect files
const auto clangResourceDirAndVersion = const auto clangIncludeDirAndVersion =
getClangResourceDirAndVersion(runControl()->runnable().executable); getClangIncludeDirAndVersion(runControl()->runnable().executable);
const AnalyzeUnits unitsToProcess = unitsToAnalyze(clangResourceDirAndVersion.first, const AnalyzeUnits unitsToProcess = unitsToAnalyze(clangIncludeDirAndVersion.first,
clangResourceDirAndVersion.second); clangIncludeDirAndVersion.second);
qCDebug(LOG) << "Files to process:" << unitsToProcess; qCDebug(LOG) << "Files to process:" << unitsToProcess;
m_queue.clear(); m_queue.clear();

View File

@@ -93,7 +93,7 @@ private:
QList<RunnerCreator> runnerCreators(); QList<RunnerCreator> runnerCreators();
template <class T> ClangToolRunner *createRunner(); template <class T> ClangToolRunner *createRunner();
AnalyzeUnits unitsToAnalyze(const Utils::FilePath &clangResourceDir, AnalyzeUnits unitsToAnalyze(const Utils::FilePath &clangIncludeDir,
const QString &clangVersion); const QString &clangVersion);
void analyzeNextFile(); void analyzeNextFile();

View File

@@ -203,13 +203,13 @@ static QString queryVersion(const FilePath &clangToolPath)
return {}; return {};
} }
QPair<FilePath, QString> getClangResourceDirAndVersion(const FilePath &clangToolPath) QPair<FilePath, QString> getClangIncludeDirAndVersion(const FilePath &clangToolPath)
{ {
const FilePath dynamicResourceDir = queryResourceDir(clangToolPath); const FilePath dynamicResourceDir = queryResourceDir(clangToolPath);
const QString dynamicVersion = queryVersion(clangToolPath); const QString dynamicVersion = queryVersion(clangToolPath);
if (dynamicResourceDir.isEmpty() || dynamicVersion.isEmpty()) if (dynamicResourceDir.isEmpty() || dynamicVersion.isEmpty())
return qMakePair(FilePath::fromString(CLANG_RESOURCE_DIR), QString(CLANG_VERSION)); return qMakePair(FilePath::fromString(CLANG_INCLUDE_DIR), QString(CLANG_VERSION));
return qMakePair(dynamicResourceDir, dynamicVersion); return qMakePair(dynamicResourceDir + "/include", dynamicVersion);
} }
} // namespace Internal } // namespace Internal

View File

@@ -34,7 +34,7 @@
namespace ClangTools { namespace ClangTools {
namespace Internal { namespace Internal {
QPair<Utils::FilePath, QString> getClangResourceDirAndVersion(const Utils::FilePath &clangToolPath); QPair<Utils::FilePath, QString> getClangIncludeDirAndVersion(const Utils::FilePath &clangToolPath);
class ClangTidyInfo class ClangTidyInfo
{ {

View File

@@ -491,11 +491,11 @@ static QString clangIncludePath(const QString &clangVersion)
\internal \internal
*/ */
QString ICore::clangIncludeDirectory(const QString &clangVersion, QString ICore::clangIncludeDirectory(const QString &clangVersion,
const QString &clangResourceDirectory) const QString &clangFallbackIncludeDir)
{ {
QDir dir(libexecPath() + "/clang" + clangIncludePath(clangVersion)); QDir dir(libexecPath() + "/clang" + clangIncludePath(clangVersion));
if (!dir.exists() || !QFileInfo(dir, "stdint.h").exists()) if (!dir.exists() || !QFileInfo(dir, "stdint.h").exists())
dir = QDir(clangResourceDirectory); dir = QDir(clangFallbackIncludeDir);
return QDir::toNativeSeparators(dir.canonicalPath()); return QDir::toNativeSeparators(dir.canonicalPath());
} }

View File

@@ -161,7 +161,7 @@ public:
static QString clangTidyExecutable(const QString &clangBinDirectory); static QString clangTidyExecutable(const QString &clangBinDirectory);
static QString clazyStandaloneExecutable(const QString &clangBinDirectory); static QString clazyStandaloneExecutable(const QString &clangBinDirectory);
static QString clangIncludeDirectory(const QString &clangVersion, static QString clangIncludeDirectory(const QString &clangVersion,
const QString &clangResourceDirectory); const QString &clangFallbackIncludeDir);
static QString buildCompatibilityString(); static QString buildCompatibilityString();
static QStatusBar *statusBar(); static QStatusBar *statusBar();

View File

@@ -105,14 +105,14 @@ CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart,
UseLanguageDefines useLanguageDefines, UseLanguageDefines useLanguageDefines,
UseBuildSystemWarnings useBuildSystemWarnings, UseBuildSystemWarnings useBuildSystemWarnings,
const QString &clangVersion, const QString &clangVersion,
const QString &clangResourceDirectory) const QString &clangIncludeDirectory)
: m_projectPart(projectPart) : m_projectPart(projectPart)
, m_useSystemHeader(useSystemHeader) , m_useSystemHeader(useSystemHeader)
, m_useTweakedHeaderPaths(useTweakedHeaderPaths) , m_useTweakedHeaderPaths(useTweakedHeaderPaths)
, m_useLanguageDefines(useLanguageDefines) , m_useLanguageDefines(useLanguageDefines)
, m_useBuildSystemWarnings(useBuildSystemWarnings) , m_useBuildSystemWarnings(useBuildSystemWarnings)
, m_clangVersion(clangVersion) , m_clangVersion(clangVersion)
, m_clangResourceDirectory(clangResourceDirectory) , m_clangIncludeDirectory(clangIncludeDirectory)
{ {
} }
@@ -332,7 +332,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
HeaderPathFilter filter{m_projectPart, HeaderPathFilter filter{m_projectPart,
m_useTweakedHeaderPaths, m_useTweakedHeaderPaths,
m_clangVersion, m_clangVersion,
m_clangResourceDirectory}; m_clangIncludeDirectory};
filter.process(); filter.process();

View File

@@ -45,14 +45,13 @@ CPPTOOLS_EXPORT QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind,
class CPPTOOLS_EXPORT CompilerOptionsBuilder class CPPTOOLS_EXPORT CompilerOptionsBuilder
{ {
public: public:
CompilerOptionsBuilder( CompilerOptionsBuilder(const ProjectPart &projectPart,
const ProjectPart &projectPart,
UseSystemHeader useSystemHeader = UseSystemHeader::No, UseSystemHeader useSystemHeader = UseSystemHeader::No,
UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::No, UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::No,
UseLanguageDefines useLanguageDefines = UseLanguageDefines::No, UseLanguageDefines useLanguageDefines = UseLanguageDefines::No,
UseBuildSystemWarnings useBuildSystemWarnings = UseBuildSystemWarnings::No, UseBuildSystemWarnings useBuildSystemWarnings = UseBuildSystemWarnings::No,
const QString &clangVersion = QString(), const QString &clangVersion = QString(),
const QString &clangResourceDirectory = QString()); const QString &clangIncludeDirectory = QString());
QStringList build(ProjectFile::Kind fileKind, UsePrecompiledHeaders usePrecompiledHeaders); QStringList build(ProjectFile::Kind fileKind, UsePrecompiledHeaders usePrecompiledHeaders);
QStringList options() const { return m_options; } QStringList options() const { return m_options; }
@@ -112,7 +111,7 @@ private:
const UseBuildSystemWarnings m_useBuildSystemWarnings; const UseBuildSystemWarnings m_useBuildSystemWarnings;
const QString m_clangVersion; const QString m_clangVersion;
const QString m_clangResourceDirectory; const QString m_clangIncludeDirectory;
struct { struct {
QStringList flags; QStringList flags;

View File

@@ -104,14 +104,14 @@ void HeaderPathFilter::filterHeaderPath(const ProjectExplorer::HeaderPath &heade
namespace { namespace {
QString clangIncludeDirectory(const QString &clangVersion, const QString &clangResourceDirectory) QString clangIncludeDirectory(const QString &clangVersion, const QString &clangFallbackIncludeDir)
{ {
#ifndef UNIT_TESTS #ifndef UNIT_TESTS
return Core::ICore::clangIncludeDirectory(clangVersion, clangResourceDirectory); return Core::ICore::clangIncludeDirectory(clangVersion, clangFallbackIncludeDir);
#else #else
Q_UNUSED(clangVersion) Q_UNUSED(clangVersion)
Q_UNUSED(clangResourceDirectory) Q_UNUSED(clangFallbackIncludeDir)
return {CLANG_RESOURCE_DIR}; return {CLANG_INCLUDE_DIR};
#endif #endif
} }
@@ -158,7 +158,8 @@ void HeaderPathFilter::tweakHeaderPaths()
auto split = resourceIterator(builtInHeaderPaths); auto split = resourceIterator(builtInHeaderPaths);
if (!clangVersion.isEmpty()) { if (!clangVersion.isEmpty()) {
const QString clangIncludePath = clangIncludeDirectory(clangVersion, clangResourceDirectory); const QString clangIncludePath
= clangIncludeDirectory(clangVersion, clangFallbackIncludeDirectory);
builtInHeaderPaths.insert(split, HeaderPath{clangIncludePath, HeaderPathType::BuiltIn}); builtInHeaderPaths.insert(split, HeaderPath{clangIncludePath, HeaderPathType::BuiltIn});
} }
} }

View File

@@ -35,12 +35,12 @@ public:
HeaderPathFilter(const ProjectPart &projectPart, HeaderPathFilter(const ProjectPart &projectPart,
UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::Yes, UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::Yes,
const QString &clangVersion = {}, const QString &clangVersion = {},
const QString &clangResourceDirectory = {}, const QString &clangIncludeDirectory = {},
const QString &projectDirectory = {}, const QString &projectDirectory = {},
const QString &buildDirectory = {}) const QString &buildDirectory = {})
: projectPart{projectPart} : projectPart{projectPart}
, clangVersion{clangVersion} , clangVersion{clangVersion}
, clangResourceDirectory{clangResourceDirectory} , clangFallbackIncludeDirectory{clangIncludeDirectory}
, projectDirectory(ensurePathWithSlashEnding(projectDirectory)) , projectDirectory(ensurePathWithSlashEnding(projectDirectory))
, buildDirectory(ensurePathWithSlashEnding(buildDirectory)) , buildDirectory(ensurePathWithSlashEnding(buildDirectory))
, useTweakedHeaderPaths{useTweakedHeaderPaths} , useTweakedHeaderPaths{useTweakedHeaderPaths}
@@ -67,7 +67,7 @@ public:
ProjectExplorer::HeaderPaths userHeaderPaths; ProjectExplorer::HeaderPaths userHeaderPaths;
const ProjectPart &projectPart; const ProjectPart &projectPart;
const QString clangVersion; const QString clangVersion;
const QString clangResourceDirectory; const QString clangFallbackIncludeDirectory;
const QString projectDirectory; const QString projectDirectory;
const QString buildDirectory; const QString buildDirectory;
const UseTweakedHeaderPaths useTweakedHeaderPaths; const UseTweakedHeaderPaths useTweakedHeaderPaths;

View File

@@ -1,5 +1,5 @@
DEFINES += CLANG_VERSION=\\\"$${LLVM_VERSION}\\\" DEFINES += CLANG_VERSION=\\\"$${LLVM_VERSION}\\\"
CLANG_RESOURCE_DIR=$$clean_path($${LLVM_LIBDIR}/clang/$${LLVM_VERSION}/include) CLANG_INCLUDE_DIR=$$clean_path($${LLVM_LIBDIR}/clang/$${LLVM_VERSION}/include)
DEFINES += "\"CLANG_RESOURCE_DIR=\\\"$${CLANG_RESOURCE_DIR}\\\"\"" DEFINES += "\"CLANG_INCLUDE_DIR=\\\"$${CLANG_INCLUDE_DIR}\\\"\""
CLANG_BINDIR=$$clean_path($${LLVM_BINDIR}) CLANG_BINDIR=$$clean_path($${LLVM_BINDIR})
DEFINES += "\"CLANG_BINDIR=\\\"$${CLANG_BINDIR}\\\"\"" DEFINES += "\"CLANG_BINDIR=\\\"$${CLANG_BINDIR}\\\"\""

View File

@@ -208,7 +208,7 @@ TEST_F(CompilerOptionsBuilder, HeaderPathOptionsOrder)
"-nostdinc++", "-nostdinc++",
"-I", toNative("/tmp/path"), "-I", toNative("/tmp/path"),
"-I", toNative("/tmp/system_path"), "-I", toNative("/tmp/system_path"),
"-isystem", toNative(CLANG_RESOURCE_DIR ""), "-isystem", toNative(CLANG_INCLUDE_DIR ""),
"-isystem", toNative("/tmp/builtin_path"))); "-isystem", toNative("/tmp/builtin_path")));
} }
@@ -232,7 +232,7 @@ TEST_F(CompilerOptionsBuilder, HeaderPathOptionsOrderCl)
"-I", toNative("/tmp/path"), "-I", toNative("/tmp/path"),
"-I", toNative("/tmp/system_path"), "-I", toNative("/tmp/system_path"),
"/clang:-isystem", "/clang:-isystem",
"/clang:" + toNative(CLANG_RESOURCE_DIR ""), "/clang:" + toNative(CLANG_INCLUDE_DIR ""),
"/clang:-isystem", "/clang:-isystem",
"/clang:" + toNative("/tmp/builtin_path"))); "/clang:" + toNative("/tmp/builtin_path")));
} }
@@ -254,7 +254,7 @@ TEST_F(CompilerOptionsBuilder, UseSystemHeader)
"-nostdinc++", "-nostdinc++",
"-I", toNative("/tmp/path"), "-I", toNative("/tmp/path"),
"-isystem", toNative("/tmp/system_path"), "-isystem", toNative("/tmp/system_path"),
"-isystem", toNative(CLANG_RESOURCE_DIR ""), "-isystem", toNative(CLANG_INCLUDE_DIR ""),
"-isystem", toNative("/tmp/builtin_path"))); "-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"),
"-isystem", toNative("/usr/include/c++/4.2.1/backward"), "-isystem", toNative("/usr/include/c++/4.2.1/backward"),
"-isystem", toNative("/usr/local/include"), "-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("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"),
"-isystem", toNative("/usr/include"), "-isystem", toNative("/usr/include"),
"-isystem", toNative("/tmp/builtin_path"))); "-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/c++/4.8/backward"),
"-isystem", toNative("/usr/include/x86_64-linux-gnu/c++/4.8"), "-isystem", toNative("/usr/include/x86_64-linux-gnu/c++/4.8"),
"-isystem", toNative("/usr/local/include"), "-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/lib/gcc/x86_64-linux-gnu/4.8/include"),
"-isystem", toNative("/usr/include/x86_64-linux-gnu"), "-isystem", toNative("/usr/include/x86_64-linux-gnu"),
"-isystem", toNative("/usr/include"))); "-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++"),
"-isystem", toNative("C:/mingw530/i686-w64-mingw32/include/c++/i686-w64-mingw32"), "-isystem", toNative("C:/mingw530/i686-w64-mingw32/include/c++/i686-w64-mingw32"),
"-isystem", toNative("C:/mingw530/i686-w64-mingw32/include/c++/backward"), "-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"))); "-isystem", toNative("C:/mingw530/i686-w64-mingw32/include")));
} }
@@ -395,7 +395,7 @@ TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderAndroidClang)
"-nostdinc++", "-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++/include"),
"-isystem", toNative("C:/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++abi/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/sysroot/usr/include/i686-linux-android"),
"-isystem", toNative("C:/Android/sdk/ndk-bundle/sources/android/support/include"), "-isystem", toNative("C:/Android/sdk/ndk-bundle/sources/android/support/include"),
"-isystem", toNative("C:/Android/sdk/ndk-bundle/sysroot/usr/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", IsPartOfHeader(toNative("wrappedQtHeaders/QtCore").toStdString()),
"-I", toNative("/tmp/path"), "-I", toNative("/tmp/path"),
"-I", toNative("/tmp/system_path"), "-I", toNative("/tmp/system_path"),
"-isystem", toNative(CLANG_RESOURCE_DIR ""), "-isystem", toNative(CLANG_INCLUDE_DIR ""),
"-isystem", toNative("/tmp/builtin_path"))); "-isystem", toNative("/tmp/builtin_path")));
} }
@@ -695,7 +695,7 @@ TEST_F(CompilerOptionsBuilder, BuildAllOptionsCl)
"-I", toNative("/tmp/path"), "-I", toNative("/tmp/path"),
"-I", toNative("/tmp/system_path"), "-I", toNative("/tmp/system_path"),
"/clang:-isystem", "/clang:-isystem",
"/clang:" + toNative(CLANG_RESOURCE_DIR ""), "/clang:" + toNative(CLANG_INCLUDE_DIR ""),
"/clang:-isystem", "/clang:-isystem",
"/clang:" + toNative("/tmp/builtin_path"))); "/clang:" + toNative("/tmp/builtin_path")));
} }

View File

@@ -26,7 +26,7 @@ include($$PWD/../../../src/plugins/clangcodemodel/clangcodemodelunittestfiles.pr
!isEmpty(CLANGFORMAT_LIBS): include($$PWD/../../../src/plugins/clangformat/clangformat-source.pri) !isEmpty(CLANGFORMAT_LIBS): include($$PWD/../../../src/plugins/clangformat/clangformat-source.pri)
} else { } else {
DEFINES += CLANG_VERSION=\\\"6.0.0\\\" DEFINES += CLANG_VERSION=\\\"6.0.0\\\"
DEFINES += "\"CLANG_RESOURCE_DIR=\\\"/usr/include\\\"\"" DEFINES += "\"CLANG_INCLUDE_DIR=\\\"/usr/include\\\"\""
} }
INCLUDEPATH += \ INCLUDEPATH += \

View File

@@ -162,12 +162,12 @@ TEST_F(HeaderPathFilter, ClangHeadersPath)
CppTools::HeaderPathFilter filter{projectPart, CppTools::HeaderPathFilter filter{projectPart,
CppTools::UseTweakedHeaderPaths::Yes, CppTools::UseTweakedHeaderPaths::Yes,
"6.0", "6.0",
CLANG_RESOURCE_DIR}; CLANG_INCLUDE_DIR};
filter.process(); filter.process();
ASSERT_THAT(filter.builtInHeaderPaths, ASSERT_THAT(filter.builtInHeaderPaths,
ElementsAre(HasBuiltIn(CLANG_RESOURCE_DIR), HasBuiltIn("/builtin_path"))); ElementsAre(HasBuiltIn(CLANG_INCLUDE_DIR), HasBuiltIn("/builtin_path")));
} }
TEST_F(HeaderPathFilter, ClangHeadersPathWitoutClangVersion) TEST_F(HeaderPathFilter, ClangHeadersPathWitoutClangVersion)
@@ -198,7 +198,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderMacOs)
CppTools::HeaderPathFilter filter{projectPart, CppTools::HeaderPathFilter filter{projectPart,
CppTools::UseTweakedHeaderPaths::Yes, CppTools::UseTweakedHeaderPaths::Yes,
"6.0", "6.0",
CLANG_RESOURCE_DIR}; CLANG_INCLUDE_DIR};
filter.process(); filter.process();
@@ -206,7 +206,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderMacOs)
ElementsAre(HasBuiltIn("/usr/include/c++/4.2.1"), ElementsAre(HasBuiltIn("/usr/include/c++/4.2.1"),
HasBuiltIn("/usr/include/c++/4.2.1/backward"), HasBuiltIn("/usr/include/c++/4.2.1/backward"),
HasBuiltIn("/usr/local/include"), HasBuiltIn("/usr/local/include"),
HasBuiltIn(CLANG_RESOURCE_DIR), HasBuiltIn(CLANG_INCLUDE_DIR),
HasBuiltIn("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"), HasBuiltIn("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"),
HasBuiltIn("/usr/include"), HasBuiltIn("/usr/include"),
HasBuiltIn("/builtin_path"))); HasBuiltIn("/builtin_path")));
@@ -229,7 +229,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderLinux)
CppTools::HeaderPathFilter filter{projectPart, CppTools::HeaderPathFilter filter{projectPart,
CppTools::UseTweakedHeaderPaths::Yes, CppTools::UseTweakedHeaderPaths::Yes,
"6.0", "6.0",
CLANG_RESOURCE_DIR}; CLANG_INCLUDE_DIR};
filter.process(); filter.process();
@@ -238,7 +238,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderLinux)
HasBuiltIn("/usr/include/c++/4.8/backward"), HasBuiltIn("/usr/include/c++/4.8/backward"),
HasBuiltIn("/usr/include/x86_64-linux-gnu/c++/4.8"), HasBuiltIn("/usr/include/x86_64-linux-gnu/c++/4.8"),
HasBuiltIn("/usr/local/include"), 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/lib/gcc/x86_64-linux-gnu/4.8/include"),
HasBuiltIn("/usr/include/x86_64-linux-gnu"), HasBuiltIn("/usr/include/x86_64-linux-gnu"),
HasBuiltIn("/usr/include"), HasBuiltIn("/usr/include"),
@@ -258,11 +258,11 @@ TEST_F(HeaderPathFilter, RemoveGccInternalPaths)
CppTools::HeaderPathFilter filter{projectPart, CppTools::HeaderPathFilter filter{projectPart,
CppTools::UseTweakedHeaderPaths::Yes, CppTools::UseTweakedHeaderPaths::Yes,
"6.0", "6.0",
CLANG_RESOURCE_DIR}; CLANG_INCLUDE_DIR};
filter.process(); 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 "<installdir>/include/c++" (MinGW) // Some distributions ship the standard library headers in "<installdir>/include/c++" (MinGW)
@@ -280,12 +280,12 @@ TEST_F(HeaderPathFilter, RemoveGccInternalPathsExceptForStandardPaths)
}; };
auto expected = projectPart.headerPaths; auto expected = projectPart.headerPaths;
expected << builtIn(CLANG_RESOURCE_DIR); expected << builtIn(CLANG_INCLUDE_DIR);
CppTools::HeaderPathFilter filter{projectPart, CppTools::HeaderPathFilter filter{projectPart,
CppTools::UseTweakedHeaderPaths::Yes, CppTools::UseTweakedHeaderPaths::Yes,
"6.0", "6.0",
CLANG_RESOURCE_DIR}; CLANG_INCLUDE_DIR};
filter.process(); filter.process();
@@ -304,7 +304,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderNoVersion)
CppTools::HeaderPathFilter filter{projectPart, CppTools::HeaderPathFilter filter{projectPart,
CppTools::UseTweakedHeaderPaths::Yes, CppTools::UseTweakedHeaderPaths::Yes,
"6.0", "6.0",
CLANG_RESOURCE_DIR}; CLANG_INCLUDE_DIR};
filter.process(); filter.process();
@@ -313,7 +313,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderNoVersion)
ElementsAre(HasBuiltIn("C:/mingw/i686-w64-mingw32/include/c++"), 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++/i686-w64-mingw32"),
HasBuiltIn("C:/mingw/i686-w64-mingw32/include/c++/backward"), HasBuiltIn("C:/mingw/i686-w64-mingw32/include/c++/backward"),
HasBuiltIn(CLANG_RESOURCE_DIR), HasBuiltIn(CLANG_INCLUDE_DIR),
HasBuiltIn("C:/mingw/i686-w64-mingw32/include"))); HasBuiltIn("C:/mingw/i686-w64-mingw32/include")));
} }
@@ -330,7 +330,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderAndroidClang)
CppTools::HeaderPathFilter filter{projectPart, CppTools::HeaderPathFilter filter{projectPart,
CppTools::UseTweakedHeaderPaths::Yes, CppTools::UseTweakedHeaderPaths::Yes,
"6.0", "6.0",
CLANG_RESOURCE_DIR}; CLANG_INCLUDE_DIR};
filter.process(); filter.process();
@@ -338,7 +338,7 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderAndroidClang)
filter.builtInHeaderPaths, filter.builtInHeaderPaths,
ElementsAre(HasBuiltIn("C:/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include"), 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("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/sysroot/usr/include/i686-linux-android"),
HasBuiltIn("C:/Android/sdk/ndk-bundle/sources/android/support/include"), HasBuiltIn("C:/Android/sdk/ndk-bundle/sources/android/support/include"),
HasBuiltIn("C:/Android/sdk/ndk-bundle/sysroot/usr/include"))); HasBuiltIn("C:/Android/sdk/ndk-bundle/sysroot/usr/include")));

View File

@@ -125,7 +125,7 @@ protected:
arguments.clone(), arguments.clone(),
Utils::clone(compilerMacros), Utils::clone(compilerMacros),
{{"project/.pre_includes", 1, ClangBackEnd::IncludeSearchPathType::System}, {{"project/.pre_includes", 1, ClangBackEnd::IncludeSearchPathType::System},
{CLANG_RESOURCE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}}, {CLANG_INCLUDE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}},
{}, {},
{filePathId(headerPaths[1])}, {filePathId(headerPaths[1])},
{filePathIds(sourcePaths)}, {filePathIds(sourcePaths)},
@@ -136,7 +136,7 @@ protected:
arguments2.clone(), arguments2.clone(),
Utils::clone(compilerMacros), Utils::clone(compilerMacros),
{{"project/.pre_includes", 1, ClangBackEnd::IncludeSearchPathType::System}, {{"project/.pre_includes", 1, ClangBackEnd::IncludeSearchPathType::System},
{CLANG_RESOURCE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}}, {CLANG_INCLUDE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}},
{}, {},
{filePathId(headerPaths[1])}, {filePathId(headerPaths[1])},
{filePathIds(sourcePaths)}, {filePathIds(sourcePaths)},
@@ -386,7 +386,7 @@ TEST_F(ProjectUpdater, CreateSortedIncludeSearchPaths)
Eq(IncludeSearchPath{builtInPath.path, 5, IncludeSearchPathType::BuiltIn}), Eq(IncludeSearchPath{builtInPath.path, 5, IncludeSearchPathType::BuiltIn}),
Eq(IncludeSearchPath{frameworkPath.path, 3, IncludeSearchPathType::Framework}), Eq(IncludeSearchPath{frameworkPath.path, 3, IncludeSearchPathType::Framework}),
Eq(IncludeSearchPath{"project/.pre_includes", 1, IncludeSearchPathType::System}), Eq(IncludeSearchPath{"project/.pre_includes", 1, IncludeSearchPathType::System}),
Eq(IncludeSearchPath{CLANG_RESOURCE_DIR, Eq(IncludeSearchPath{CLANG_INCLUDE_DIR,
4, 4,
ClangBackEnd::IncludeSearchPathType::BuiltIn}))); ClangBackEnd::IncludeSearchPathType::BuiltIn})));
ASSERT_THAT(paths.project, ASSERT_THAT(paths.project,