Clang: Avoid consuming gcc internal include paths

Given the (default) include paths of GCC, e.g.

 /usr/include/c++/7
 /usr/include/x86_64-linux-gnu/c++/7
 /usr/include/c++/7/backward
 /usr/lib/gcc/x86_64-linux-gnu/7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include

discard gcc-internal paths like /usr/lib/gcc/x86_64-linux-gnu/7/include
as they are not relevant for clang and even confuse it with regard to
 #include_next.

Paths below the gcc install dir are considered as gcc-internal. The
install dir is queried with

  $ gcc -print-search-dirs

Some GCC distributions, like MinGW, ship the standard library headers in
the install dir. Ensure to not discard these.

Fixes: QTCREATORBUG-22898
Change-Id: Ia85258fb01b72ad073e71390e003fe8268e3b01f
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-10-10 11:04:01 +02:00
parent 7a87dc0484
commit 5165c037eb
12 changed files with 137 additions and 0 deletions

View File

@@ -184,6 +184,7 @@ ToolChainInfo::ToolChainInfo(const ToolChain *toolChain,
wordWidth = toolChain->targetAbi().wordWidth();
targetTriple = toolChain->originalTargetTriple();
extraCodeModelFlags = toolChain->extraCodeModelFlags();
installDir = toolChain->installDir();
// ...and save the potentially expensive operations for later so that
// they can be run from a worker thread.