forked from qt-creator/qt-creator
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:
@@ -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")));
|
||||
}
|
||||
|
||||
@@ -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 += \
|
||||
|
||||
@@ -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 "<installdir>/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")));
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user