forked from qt-creator/qt-creator
ClangSupport: Fix CommandLineBuilder
Forgot to add macros. Change-Id: I4a5ab969a6b99c110b3ffd9e8f2b59560ccfc8b9 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -52,6 +52,7 @@ public:
|
||||
addLanguage(projectInfo);
|
||||
addLanguageVersion(projectInfo);
|
||||
addNoStdIncAndNoStdLibInc();
|
||||
addCompilerMacros(projectInfo.compilerMacros);
|
||||
addProjectIncludeSearchPaths(
|
||||
sortedIncludeSearchPaths(projectInfo.projectIncludeSearchPaths));
|
||||
addSystemAndBuiltInIncludeSearchPaths(
|
||||
@@ -177,6 +178,20 @@ public:
|
||||
commandLine.emplace_back(standardLanguageVersion(projectInfo.languageVersion));
|
||||
}
|
||||
|
||||
void addCompilerMacros(const CompilerMacros &compilerMacros)
|
||||
{
|
||||
CompilerMacros macros = compilerMacros;
|
||||
|
||||
std::sort(macros.begin(),
|
||||
macros.end(),
|
||||
[](const CompilerMacro &first, const CompilerMacro &second) {
|
||||
return first.index < second.index;
|
||||
});
|
||||
|
||||
for (const CompilerMacro ¯o : macros)
|
||||
commandLine.emplace_back(Utils::SmallString{"-D", macro.key, "=", macro.value});
|
||||
}
|
||||
|
||||
IncludeSearchPaths sortedIncludeSearchPaths(const IncludeSearchPaths &unsortedPaths)
|
||||
{
|
||||
IncludeSearchPaths paths = unsortedPaths;
|
||||
|
@@ -509,4 +509,20 @@ TYPED_TEST(CommandLineBuilder, IncludePchPath)
|
||||
"/source/file.cpp"));
|
||||
}
|
||||
|
||||
TYPED_TEST(CommandLineBuilder, CompilerMacros)
|
||||
{
|
||||
this->emptyProjectInfo.compilerMacros = {{"YI", "1", 2}, {"ER", "2", 1}};
|
||||
|
||||
Builder<TypeParam> builder{this->emptyProjectInfo};
|
||||
|
||||
ASSERT_THAT(builder.commandLine,
|
||||
ElementsAre("clang++",
|
||||
"-x",
|
||||
"c++-header",
|
||||
"-std=c++98",
|
||||
"-nostdinc",
|
||||
"-nostdlibinc",
|
||||
"-DER=2",
|
||||
"-DYI=1"));
|
||||
}
|
||||
} // namespace
|
||||
|
@@ -270,6 +270,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollector)
|
||||
"-std=c++14",
|
||||
"-nostdinc",
|
||||
"-nostdlibinc",
|
||||
"-DBAR=1",
|
||||
"-DFOO=1",
|
||||
"-I",
|
||||
"/project/includes",
|
||||
"-I",
|
||||
@@ -298,6 +300,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInColl
|
||||
"-std=c++14",
|
||||
"-nostdinc",
|
||||
"-nostdlibinc",
|
||||
"-DBAR=1",
|
||||
"-DFOO=1",
|
||||
"-I",
|
||||
"/project/includes",
|
||||
"-I",
|
||||
@@ -329,6 +333,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithoutPrecompiledHeaderInC
|
||||
"-std=c++14",
|
||||
"-nostdinc",
|
||||
"-nostdlibinc",
|
||||
"-DBAR=1",
|
||||
"-DFOO=1",
|
||||
"-I",
|
||||
"/project/includes",
|
||||
"-I",
|
||||
@@ -507,6 +513,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrderWithoutProjectPartArtifact)
|
||||
"-std=c++14",
|
||||
"-nostdinc",
|
||||
"-nostdlibinc",
|
||||
"-DBAR=1",
|
||||
"-DFOO=1",
|
||||
"-I",
|
||||
"/project/includes",
|
||||
"-I",
|
||||
@@ -557,6 +565,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrderWithProjectPartArtifact)
|
||||
"-std=c++14",
|
||||
"-nostdinc",
|
||||
"-nostdlibinc",
|
||||
"-DBAR=1",
|
||||
"-DFOO=1",
|
||||
"-I",
|
||||
"/project/includes",
|
||||
"-I",
|
||||
@@ -611,6 +621,8 @@ TEST_F(SymbolIndexer, UpdateChangedPathCallsInOrder)
|
||||
"-std=c++14",
|
||||
"-nostdinc",
|
||||
"-nostdlibinc",
|
||||
"-DBAR=1",
|
||||
"-DFOO=1",
|
||||
"-I",
|
||||
"/project/includes",
|
||||
"-I",
|
||||
@@ -671,6 +683,8 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsUsingPrecompiledHeader)
|
||||
"-std=c++14",
|
||||
"-nostdinc",
|
||||
"-nostdlibinc",
|
||||
"-DBAR=1",
|
||||
"-DFOO=1",
|
||||
"-I",
|
||||
"/project/includes",
|
||||
"-I",
|
||||
@@ -704,6 +718,8 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsNotUsingPrecompiledHeaderIfItNotExists)
|
||||
"-std=c++14",
|
||||
"-nostdinc",
|
||||
"-nostdlibinc",
|
||||
"-DBAR=1",
|
||||
"-DFOO=1",
|
||||
"-I",
|
||||
"/project/includes",
|
||||
"-I",
|
||||
|
Reference in New Issue
Block a user