Clang: Fix how tweaked header paths work

We need to provide built-in includes only when we use tweaked headers.
Also let's require Clang resource directory because it has to be
placed on the specific position inside the built-in header paths.

Change-Id: Id581238660c680725201de759216cf33f69f6cc7
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2019-01-17 15:27:36 +01:00
parent 87746b5906
commit 093673e9cf
3 changed files with 205 additions and 134 deletions

View File

@@ -296,27 +296,22 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
using ProjectExplorer::HeaderPath;
using ProjectExplorer::HeaderPathType;
for (const HeaderPath &headerPath : filter.userHeaderPaths)
addIncludeDirOptionForPath(headerPath);
for (const HeaderPath &headerPath : filter.systemHeaderPaths)
addIncludeDirOptionForPath(headerPath);
if (m_useTweakedHeaderPaths == UseTweakedHeaderPaths::Yes) {
// Exclude all built-in includes except Clang resource directory.
QTC_CHECK(!m_clangVersion.isEmpty()
&& "Clang resource directory is required with UseTweakedHeaderPaths::Yes.");
if (!isClStyle()) // MSVC does not have such include directories - ignore it for cl driver.
m_options.prepend("-nostdlibinc");
// Exclude all built-in includes and Clang resource directory.
m_options.prepend("-nostdinc++");
m_options.prepend("-nostdinc");
if (!m_clangVersion.isEmpty()) {
// Exclude all built-in includes and Clang resource directory.
m_options.prepend("-nostdinc");
}
for (const HeaderPath &headerPath : filter.builtInHeaderPaths)
addIncludeDirOptionForPath(headerPath);
}
for (const HeaderPath &headerPath : qAsConst(filter.userHeaderPaths))
addIncludeDirOptionForPath(headerPath);
for (const HeaderPath &headerPath : qAsConst(filter.systemHeaderPaths))
addIncludeDirOptionForPath(headerPath);
for (const HeaderPath &headerPath : qAsConst(filter.builtInHeaderPaths))
addIncludeDirOptionForPath(headerPath);
}
void CompilerOptionsBuilder::addPrecompiledHeaderOptions(UsePrecompiledHeaders usePrecompiledHeaders)

View File

@@ -45,7 +45,7 @@ class CPPTOOLS_EXPORT CompilerOptionsBuilder
public:
CompilerOptionsBuilder(const ProjectPart &projectPart,
UseSystemHeader useSystemHeader = UseSystemHeader::No,
UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::Yes,
UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::No,
UseLanguageDefines useLanguageDefines = UseLanguageDefines::No,
const QString &clangVersion = QString(),
const QString &clangResourceDirectory = QString());