Clang: Fix command line builder

Add "-nostdinc++" only for C++.

Change-Id: I21228fca80045b040877328f41ca0edb4f227fcc
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2019-02-12 16:24:34 +01:00
parent 80cdc99737
commit a33bce9e91
2 changed files with 12 additions and 9 deletions

View File

@@ -54,7 +54,7 @@ public:
addToolChainArguments(toolChainArguments); addToolChainArguments(toolChainArguments);
addLanguage(projectInfo, sourceType); addLanguage(projectInfo, sourceType);
addLanguageVersion(projectInfo); addLanguageVersion(projectInfo);
addNoStdIncAndNoStdLibInc(); addNoStdIncAndNoStdLibInc(projectInfo.language);
addCompilerMacros(projectInfo.compilerMacros); addCompilerMacros(projectInfo.compilerMacros);
addProjectIncludeSearchPaths( addProjectIncludeSearchPaths(
sortedIncludeSearchPaths(projectInfo.projectIncludeSearchPaths)); sortedIncludeSearchPaths(projectInfo.projectIncludeSearchPaths));
@@ -272,10 +272,11 @@ public:
} }
} }
void addNoStdIncAndNoStdLibInc() void addNoStdIncAndNoStdLibInc(Utils::Language language)
{ {
commandLine.emplace_back("-nostdinc"); commandLine.emplace_back("-nostdinc");
commandLine.emplace_back("-nostdinc++"); if (language == Utils::Language::Cxx)
commandLine.emplace_back("-nostdinc++");
} }
public: public:

View File

@@ -137,9 +137,13 @@ TYPED_TEST(CommandLineBuilder, CHeader)
Builder<TypeParam> builder{this->emptyProjectInfo, {}, InputFileType::Header, "/source/file.c"}; Builder<TypeParam> builder{this->emptyProjectInfo, {}, InputFileType::Header, "/source/file.c"};
ASSERT_THAT( ASSERT_THAT(builder.commandLine,
builder.commandLine, ElementsAre("clang",
ElementsAre("clang", "-x", "c-header", "-std=c11", "-nostdinc", "-nostdinc++", toNativePath("/source/file.c").path())); "-x",
"c-header",
"-std=c11",
"-nostdinc",
toNativePath("/source/file.c").path()));
} }
TYPED_TEST(CommandLineBuilder, CSource) TYPED_TEST(CommandLineBuilder, CSource)
@@ -150,7 +154,7 @@ TYPED_TEST(CommandLineBuilder, CSource)
Builder<TypeParam> builder{this->emptyProjectInfo, {}, InputFileType::Source, "/source/file.c"}; Builder<TypeParam> builder{this->emptyProjectInfo, {}, InputFileType::Source, "/source/file.c"};
ASSERT_THAT(builder.commandLine, ASSERT_THAT(builder.commandLine,
ElementsAre("clang", "-x", "c", "-std=c11", "-nostdinc", "-nostdinc++", "/source/file.c")); ElementsAre("clang", "-x", "c", "-std=c11", "-nostdinc", "/source/file.c"));
} }
TYPED_TEST(CommandLineBuilder, ObjectiveCHeader) TYPED_TEST(CommandLineBuilder, ObjectiveCHeader)
@@ -167,7 +171,6 @@ TYPED_TEST(CommandLineBuilder, ObjectiveCHeader)
"objective-c-header", "objective-c-header",
"-std=c11", "-std=c11",
"-nostdinc", "-nostdinc",
"-nostdinc++",
toNativePath("/source/file.c").path())); toNativePath("/source/file.c").path()));
} }
@@ -185,7 +188,6 @@ TYPED_TEST(CommandLineBuilder, ObjectiveCSource)
"objective-c", "objective-c",
"-std=c11", "-std=c11",
"-nostdinc", "-nostdinc",
"-nostdinc++",
"/source/file.c")); "/source/file.c"));
} }