diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-12-05 10:36:24 +0100 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-12-11 07:49:09 +0000 |
commit | aa70799795223367a983a1cce0fcf2d165a8b0cc (patch) | |
tree | 0749da25b53aee09f5f014802fe084cbf9bbce80 /tests | |
parent | 867befc5aed42f9b3e57231e14a6a0aa430c5591 (diff) |
Clang: Always force the built-in includes order
C++ includes must always come first, then clang resource
directory and then everything else.
This prevents both c++ standard headers and intrinsics issues.
Change-Id: Ia21bfa2fe99884c9adf58f7ef6beba1bede1724b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unittest/compileroptionsbuilder-test.cpp | 108 |
1 files changed, 60 insertions, 48 deletions
diff --git a/tests/unit/unittest/compileroptionsbuilder-test.cpp b/tests/unit/unittest/compileroptionsbuilder-test.cpp index 097efd5803..b7a4ace9e6 100644 --- a/tests/unit/unittest/compileroptionsbuilder-test.cpp +++ b/tests/unit/unittest/compileroptionsbuilder-test.cpp @@ -232,11 +232,14 @@ TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderLinux) TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderNoVersion) { - projectPart.headerPaths = {HeaderPath{"C:\\Qt\\Tools\\mingw530_32\\i686-w64-mingw32\\include", HeaderPathType::BuiltIn}, - HeaderPath{"C:\\Qt\\Tools\\mingw530_32\\i686-w64-mingw32\\include\\c++", HeaderPathType::BuiltIn}, - HeaderPath{"C:\\Qt\\Tools\\mingw530_32\\i686-w64-mingw32\\include\\c++\\i686-w64-mingw32", HeaderPathType::BuiltIn}, - HeaderPath{"C:\\Qt\\Tools\\mingw530_32\\i686-w64-mingw32\\include\\c++\\backward", HeaderPathType::BuiltIn} - }; + projectPart.headerPaths = { + HeaderPath{"C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include", HeaderPathType::BuiltIn}, + HeaderPath{"C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++", + HeaderPathType::BuiltIn}, + HeaderPath{"C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/i686-w64-mingw32", + HeaderPathType::BuiltIn}, + HeaderPath{"C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/backward", + HeaderPathType::BuiltIn}}; projectPart.toolChainTargetTriple = "x86_64-w64-windows-gnu"; CppTools::CompilerOptionsBuilder compilerOptionsBuilder(projectPart, CppTools::UseSystemHeader::No, @@ -247,33 +250,43 @@ TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderNoVersion) compilerOptionsBuilder.addHeaderPathOptions(); - ASSERT_THAT(compilerOptionsBuilder.options(), - ElementsAre("-nostdinc", - "-nostdlibinc", - "-isystem", QDir::toNativeSeparators("C:\\Qt\\Tools\\mingw530_32\\i686-w64-mingw32\\include"), - "-isystem", QDir::toNativeSeparators("C:\\Qt\\Tools\\mingw530_32\\i686-w64-mingw32\\include\\c++"), - "-isystem", QDir::toNativeSeparators("C:\\Qt\\Tools\\mingw530_32\\i686-w64-mingw32\\include\\c++\\i686-w64-mingw32"), - "-isystem", QDir::toNativeSeparators("C:\\Qt\\Tools\\mingw530_32\\i686-w64-mingw32\\include\\c++\\backward"), - "-isystem", QDir::toNativeSeparators(CLANG_RESOURCE_DIR ""))); + ASSERT_THAT( + compilerOptionsBuilder.options(), + ElementsAre( + "-nostdinc", + "-nostdlibinc", + "-isystem", + QDir::toNativeSeparators("C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++"), + "-isystem", + QDir::toNativeSeparators( + "C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/i686-w64-mingw32"), + "-isystem", + QDir::toNativeSeparators( + "C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/backward"), + "-isystem", + QDir::toNativeSeparators(CLANG_RESOURCE_DIR ""), + "-isystem", + QDir::toNativeSeparators("C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include"))); } TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderAndroidClang) { - projectPart.headerPaths = { - HeaderPath{ - "C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sysroot\\usr\\include\\i686-linux-android", - HeaderPathType::BuiltIn}, - HeaderPath{ - "C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sources\\cxx-stl\\llvm-libc++\\include", - HeaderPathType::BuiltIn}, - HeaderPath{ - "C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sources\\android\\support\\include", - HeaderPathType::BuiltIn}, - HeaderPath{ - "C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sources\\cxx-stl\\llvm-libc++abi\\include", - HeaderPathType::BuiltIn}, - HeaderPath{"C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sysroot\\usr\\include", - HeaderPathType::BuiltIn}}; + projectPart.headerPaths + = {HeaderPath{"C:/Users/test/AppData/Local/Android/sdk/ndk-" + "bundle/sysroot/usr/include/i686-linux-android", + HeaderPathType::BuiltIn}, + HeaderPath{"C:/Users/test/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-" + "stl/llvm-libc++/include", + HeaderPathType::BuiltIn}, + HeaderPath{"C:/Users/test/AppData/Local/Android/sdk/ndk-" + "bundle/sources/android/support/include", + HeaderPathType::BuiltIn}, + HeaderPath{"C:/Users/test/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-" + "stl/llvm-libc++abi/include", + HeaderPathType::BuiltIn}, + HeaderPath{ + "C:/Users/test/AppData/Local/Android/sdk/ndk-bundle/sysroot/usr/include", + HeaderPathType::BuiltIn}}; projectPart.toolChainTargetTriple = "i686-linux-android"; CppTools::CompilerOptionsBuilder compilerOptionsBuilder(projectPart, CppTools::UseSystemHeader::No, @@ -286,26 +299,25 @@ TEST_F(CompilerOptionsBuilder, ClangHeadersAndCppIncludesPathsOrderAndroidClang) ASSERT_THAT( compilerOptionsBuilder.options(), - ElementsAre( - "-nostdinc", - "-nostdlibinc", - "-isystem", - QDir::toNativeSeparators( - "C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sysroot\\usr\\include\\i686-linux-android"), - "-isystem", - QDir::toNativeSeparators( - "C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sources\\cxx-stl\\llvm-libc++\\include"), - "-isystem", - QDir::toNativeSeparators( - "C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sources\\android\\support\\include"), - "-isystem", - QDir::toNativeSeparators( - "C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sources\\cxx-stl\\llvm-libc++abi\\include"), - "-isystem", - QDir::toNativeSeparators(CLANG_RESOURCE_DIR ""), - "-isystem", - QDir::toNativeSeparators( - "C:\\Users\\test\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sysroot\\usr\\include"))); + ElementsAre("-nostdinc", + "-nostdlibinc", + "-isystem", + QDir::toNativeSeparators("C:/Users/test/AppData/Local/Android/sdk/ndk-" + "bundle/sources/cxx-stl/llvm-libc++/include"), + "-isystem", + QDir::toNativeSeparators("C:/Users/test/AppData/Local/Android/sdk/ndk-" + "bundle/sources/cxx-stl/llvm-libc++abi/include"), + "-isystem", + QDir::toNativeSeparators(CLANG_RESOURCE_DIR ""), + "-isystem", + QDir::toNativeSeparators("C:/Users/test/AppData/Local/Android/sdk/ndk-" + "bundle/sysroot/usr/include/i686-linux-android"), + "-isystem", + QDir::toNativeSeparators("C:/Users/test/AppData/Local/Android/sdk/ndk-" + "bundle/sources/android/support/include"), + "-isystem", + QDir::toNativeSeparators("C:/Users/test/AppData/Local/Android/sdk/ndk-" + "bundle/sysroot/usr/include"))); } TEST_F(CompilerOptionsBuilder, NoPrecompiledHeader) |