forked from qt-creator/qt-creator
Clang: Use -isystem for system headers
The project manager was passing correctly the system headers, but the compileroptionsbuilder was ignoring them by having UseSystemHeader::No. This change makes the project's view to be reflected in clangd's compile_commands.json. Fixes: QTCREATORBUG-30474 Change-Id: Ie3b80642e27ada4c8c8725f21e3cfbb2a4051aa0 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -692,8 +692,7 @@ void CompilerOptionsBuilder::addIncludeDirOptionForPath(const HeaderPath &path)
|
||||
if (path.type == HeaderPathType::BuiltIn) {
|
||||
systemPath = true;
|
||||
} else if (path.type == HeaderPathType::System) {
|
||||
if (m_useSystemHeader == UseSystemHeader::Yes)
|
||||
systemPath = true;
|
||||
systemPath = true;
|
||||
} else {
|
||||
// ProjectExplorer::HeaderPathType::User
|
||||
if (m_useSystemHeader == UseSystemHeader::Yes && m_projectPart.hasProject()
|
||||
|
@@ -196,7 +196,7 @@ void CompilerOptionsBuilderTest::testHeaderPathOptionsOrder()
|
||||
|
||||
QCOMPARE(compilerOptionsBuilder.options(),
|
||||
(QStringList{"-nostdinc", "-nostdinc++", "-I" + t.toNative("/tmp/path"),
|
||||
"-I" + t.toNative("/tmp/system_path"), "-isystem", t.toNative("/dummy"),
|
||||
"-isystem", t.toNative("/tmp/system_path"), "-isystem", t.toNative("/dummy"),
|
||||
"-isystem", t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
|
||||
@@ -212,9 +212,9 @@ void CompilerOptionsBuilderTest::testHeaderPathOptionsOrderMsvc()
|
||||
|
||||
QCOMPARE(compilerOptionsBuilder.options(),
|
||||
(QStringList{"-nostdinc", "-nostdinc++", "-I" + t.toNative("/tmp/path"),
|
||||
"-I" + t.toNative("/tmp/system_path"), "/clang:-isystem",
|
||||
"/clang:" + t.toNative("/dummy"), "/clang:-isystem",
|
||||
"/clang:" + t.toNative("/tmp/builtin_path")}));
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/tmp/system_path"),
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/dummy"),
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
|
||||
void CompilerOptionsBuilderTest::testUseSystemHeader()
|
||||
@@ -239,7 +239,7 @@ void CompilerOptionsBuilderTest::testNoClangHeadersPath()
|
||||
t.compilerOptionsBuilder->addHeaderPathOptions();
|
||||
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(),
|
||||
(QStringList{"-I" + t.toNative("/tmp/path"), "-I" + t.toNative("/tmp/system_path")}));
|
||||
(QStringList{"-I" + t.toNative("/tmp/path"), "-isystem", t.toNative("/tmp/system_path")}));
|
||||
}
|
||||
|
||||
void CompilerOptionsBuilderTest::testClangHeadersAndCppIncludePathsOrderMacOs()
|
||||
@@ -260,7 +260,7 @@ void CompilerOptionsBuilderTest::testClangHeadersAndCppIncludePathsOrderMacOs()
|
||||
|
||||
QCOMPARE(compilerOptionsBuilder.options(),
|
||||
(QStringList{"-nostdinc", "-nostdinc++", "-I" + t.toNative("/tmp/path"),
|
||||
"-I" + t.toNative("/tmp/system_path"),
|
||||
"-isystem", t.toNative("/tmp/system_path"),
|
||||
"-isystem", t.toNative("/usr/include/c++/4.2.1"),
|
||||
"-isystem", t.toNative("/usr/include/c++/4.2.1/backward"),
|
||||
"-isystem", t.toNative("/usr/local/include"),
|
||||
@@ -599,7 +599,7 @@ void CompilerOptionsBuilderTest::testBuildAllOptions()
|
||||
wrappedQtHeadersPath, // contains -I already
|
||||
wrappedQtCoreHeadersPath, // contains -I already
|
||||
"-I" + t.toNative("/tmp/path"),
|
||||
"-I" + t.toNative("/tmp/system_path"),
|
||||
"-isystem", t.toNative("/tmp/system_path"),
|
||||
"-isystem", t.toNative("/dummy"),
|
||||
"-isystem", t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
@@ -628,7 +628,7 @@ void CompilerOptionsBuilderTest::testBuildAllOptionsMsvc()
|
||||
wrappedQtHeadersPath, // contains -I already
|
||||
wrappedQtCoreHeadersPath, // contains -I already
|
||||
"-I" + t.toNative("/tmp/path"),
|
||||
"-I" + t.toNative("/tmp/system_path"),
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/tmp/system_path"),
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/dummy"),
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
@@ -659,7 +659,7 @@ void CompilerOptionsBuilderTest::testBuildAllOptionsMsvcWithExceptions()
|
||||
wrappedQtHeadersPath, // contains -I already
|
||||
wrappedQtCoreHeadersPath, // contains -I already
|
||||
"-I" + t.toNative("/tmp/path"),
|
||||
"-I" + t.toNative("/tmp/system_path"),
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/tmp/system_path"),
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/dummy"),
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user