forked from qt-creator/qt-creator
Clang: Fix removing gcc internal include paths
Amends 5165c037eb
.
Gentoo has the standard library headers installed in e.g.
<installdir>/include/g++-v8 and we excluded those. MinGW with the
standard library headers in <installdir>/include/c++ was whitelisted.
Instead of whitelistening more dirs that could contain standard library
headers, regard
<installdir>/include
<installdir>/include-fixed
as gcc internal include paths to remove. These seem to be stable across
distributions.
Task-number: QTCREATORBUG-23330
Change-Id: I44965d2030b4ea5a9dd269400faf19c3df89f5a6
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -72,14 +72,9 @@ void HeaderPathFilter::removeGccInternalIncludePaths()
|
|||||||
|
|
||||||
const Utils::FilePath gccInstallDir = projectPart.toolChainInstallDir;
|
const Utils::FilePath gccInstallDir = projectPart.toolChainInstallDir;
|
||||||
auto isGccInternalInclude = [gccInstallDir](const HeaderPath &headerPath) {
|
auto isGccInternalInclude = [gccInstallDir](const HeaderPath &headerPath) {
|
||||||
const auto includePath = Utils::FilePath::fromString(headerPath.path);
|
const auto filePath = Utils::FilePath::fromString(headerPath.path);
|
||||||
if (includePath.isChildOf(gccInstallDir)) {
|
return filePath == gccInstallDir.pathAppended("include")
|
||||||
const QString remainingPath = headerPath.path.mid(gccInstallDir.toString().size());
|
|| filePath == gccInstallDir.pathAppended("include-fixed");
|
||||||
// MinGW ships the standard library headers in "<installdir>/include/c++".
|
|
||||||
// Ensure that we do not remove include paths pointing there.
|
|
||||||
return !remainingPath.startsWith("/include/c++");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Utils::erase(builtInHeaderPaths, isGccInternalInclude);
|
Utils::erase(builtInHeaderPaths, isGccInternalInclude);
|
||||||
|
@@ -245,7 +245,8 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderLinux)
|
|||||||
HasBuiltIn("/builtin_path")));
|
HasBuiltIn("/builtin_path")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include paths below the installation dir should be removed as they confuse clang.
|
// GCC-internal include paths like <installdir>/include and <installdir/include-next> might confuse
|
||||||
|
// clang and should be filtered out. clang on the command line filters them out, too.
|
||||||
TEST_F(HeaderPathFilter, RemoveGccInternalPaths)
|
TEST_F(HeaderPathFilter, RemoveGccInternalPaths)
|
||||||
{
|
{
|
||||||
projectPart.toolChainInstallDir = Utils::FilePath::fromUtf8("/usr/lib/gcc/x86_64-linux-gnu/7");
|
projectPart.toolChainInstallDir = Utils::FilePath::fromUtf8("/usr/lib/gcc/x86_64-linux-gnu/7");
|
||||||
@@ -264,7 +265,8 @@ TEST_F(HeaderPathFilter, RemoveGccInternalPaths)
|
|||||||
ASSERT_THAT(filter.builtInHeaderPaths, ElementsAre(HasBuiltIn(CLANG_RESOURCE_DIR)));
|
ASSERT_THAT(filter.builtInHeaderPaths, ElementsAre(HasBuiltIn(CLANG_RESOURCE_DIR)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinGW ships the standard library headers in "<installdir>/include/c++".
|
// Some distributions ship the standard library headers in "<installdir>/include/c++" (MinGW)
|
||||||
|
// or e.g. "<installdir>/include/g++-v8" (Gentoo).
|
||||||
// Ensure that we do not remove include paths pointing there.
|
// Ensure that we do not remove include paths pointing there.
|
||||||
TEST_F(HeaderPathFilter, RemoveGccInternalPathsExceptForStandardPaths)
|
TEST_F(HeaderPathFilter, RemoveGccInternalPathsExceptForStandardPaths)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user