forked from qt-creator/qt-creator
Clang: Skip built-in includes when exporting the compilation database
We don't want to have compiler-specific paths there. Change-Id: If26434ea3760d4f2ca4c25bbcf0340f4ea781072 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -89,6 +89,7 @@ public:
|
||||
LibClangOptionsBuilder(const ProjectPart &projectPart)
|
||||
: CompilerOptionsBuilder(projectPart,
|
||||
UseSystemHeader::No,
|
||||
CppTools::SkipBuiltIn::No,
|
||||
QString(CLANG_VERSION),
|
||||
QString(CLANG_RESOURCE_DIR))
|
||||
{
|
||||
@@ -348,7 +349,9 @@ void generateCompilationDB(::Utils::FileName projectDir, CppTools::ProjectInfo p
|
||||
for (ProjectPart::Ptr projectPart : projectInfo.projectParts()) {
|
||||
const ::Utils::FileName buildDir = buildDirectory(*projectPart);
|
||||
|
||||
CompilerOptionsBuilder optionsBuilder(*projectPart);
|
||||
CompilerOptionsBuilder optionsBuilder(*projectPart,
|
||||
CppTools::UseSystemHeader::No,
|
||||
CppTools::SkipBuiltIn::Yes);
|
||||
optionsBuilder.build(CppTools::ProjectFile::Unclassified,
|
||||
CppTools::CompilerOptionsBuilder::PchUsage::None);
|
||||
|
||||
|
||||
@@ -193,6 +193,7 @@ static AnalyzeUnits toAnalyzeUnits(const FileInfos &fileInfos)
|
||||
for (const FileInfo &fileInfo : fileInfos) {
|
||||
CompilerOptionsBuilder optionsBuilder(*fileInfo.projectPart,
|
||||
CppTools::UseSystemHeader::No,
|
||||
CppTools::SkipBuiltIn::No,
|
||||
QString(CLANG_VERSION),
|
||||
QString(CLANG_RESOURCE_DIR));
|
||||
QStringList arguments = extraClangToolsPrependOptions();
|
||||
|
||||
@@ -43,12 +43,14 @@ namespace CppTools {
|
||||
|
||||
CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart,
|
||||
UseSystemHeader useSystemHeader,
|
||||
SkipBuiltIn skipBuiltInHeaderPaths,
|
||||
QString clangVersion,
|
||||
QString clangResourceDirectory)
|
||||
: m_projectPart(projectPart)
|
||||
, m_useSystemHeader(useSystemHeader)
|
||||
, m_clangVersion(clangVersion)
|
||||
, m_clangResourceDirectory(clangResourceDirectory)
|
||||
, m_skipBuiltInHeaderPaths(skipBuiltInHeaderPaths)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -237,7 +239,8 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
|
||||
|
||||
m_options.append(includes);
|
||||
m_options.append(systemIncludes);
|
||||
m_options.append(builtInIncludes);
|
||||
if (m_skipBuiltInHeaderPaths == SkipBuiltIn::No)
|
||||
m_options.append(builtInIncludes);
|
||||
}
|
||||
|
||||
void CompilerOptionsBuilder::addPrecompiledHeaderOptions(PchUsage pchUsage)
|
||||
|
||||
@@ -37,6 +37,12 @@ enum class UseSystemHeader
|
||||
No
|
||||
};
|
||||
|
||||
enum class SkipBuiltIn
|
||||
{
|
||||
Yes,
|
||||
No
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT CompilerOptionsBuilder
|
||||
{
|
||||
public:
|
||||
@@ -47,6 +53,7 @@ public:
|
||||
|
||||
CompilerOptionsBuilder(const ProjectPart &projectPart,
|
||||
UseSystemHeader useSystemHeader = UseSystemHeader::No,
|
||||
SkipBuiltIn skipBuiltInHeaderPaths = SkipBuiltIn::No,
|
||||
QString clangVersion = QString(),
|
||||
QString clangResourceDirectory = QString());
|
||||
virtual ~CompilerOptionsBuilder() {}
|
||||
@@ -106,6 +113,8 @@ private:
|
||||
|
||||
QString m_clangVersion;
|
||||
QString m_clangResourceDirectory;
|
||||
|
||||
SkipBuiltIn m_skipBuiltInHeaderPaths;
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
Reference in New Issue
Block a user