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);
|
addLanguage(projectInfo);
|
||||||
addLanguageVersion(projectInfo);
|
addLanguageVersion(projectInfo);
|
||||||
addNoStdIncAndNoStdLibInc();
|
addNoStdIncAndNoStdLibInc();
|
||||||
|
addCompilerMacros(projectInfo.compilerMacros);
|
||||||
addProjectIncludeSearchPaths(
|
addProjectIncludeSearchPaths(
|
||||||
sortedIncludeSearchPaths(projectInfo.projectIncludeSearchPaths));
|
sortedIncludeSearchPaths(projectInfo.projectIncludeSearchPaths));
|
||||||
addSystemAndBuiltInIncludeSearchPaths(
|
addSystemAndBuiltInIncludeSearchPaths(
|
||||||
@@ -177,6 +178,20 @@ public:
|
|||||||
commandLine.emplace_back(standardLanguageVersion(projectInfo.languageVersion));
|
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 sortedIncludeSearchPaths(const IncludeSearchPaths &unsortedPaths)
|
||||||
{
|
{
|
||||||
IncludeSearchPaths paths = unsortedPaths;
|
IncludeSearchPaths paths = unsortedPaths;
|
||||||
|
@@ -509,4 +509,20 @@ TYPED_TEST(CommandLineBuilder, IncludePchPath)
|
|||||||
"/source/file.cpp"));
|
"/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
|
} // namespace
|
||||||
|
@@ -270,6 +270,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollector)
|
|||||||
"-std=c++14",
|
"-std=c++14",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdlibinc",
|
"-nostdlibinc",
|
||||||
|
"-DBAR=1",
|
||||||
|
"-DFOO=1",
|
||||||
"-I",
|
"-I",
|
||||||
"/project/includes",
|
"/project/includes",
|
||||||
"-I",
|
"-I",
|
||||||
@@ -298,6 +300,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInColl
|
|||||||
"-std=c++14",
|
"-std=c++14",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdlibinc",
|
"-nostdlibinc",
|
||||||
|
"-DBAR=1",
|
||||||
|
"-DFOO=1",
|
||||||
"-I",
|
"-I",
|
||||||
"/project/includes",
|
"/project/includes",
|
||||||
"-I",
|
"-I",
|
||||||
@@ -329,6 +333,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithoutPrecompiledHeaderInC
|
|||||||
"-std=c++14",
|
"-std=c++14",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdlibinc",
|
"-nostdlibinc",
|
||||||
|
"-DBAR=1",
|
||||||
|
"-DFOO=1",
|
||||||
"-I",
|
"-I",
|
||||||
"/project/includes",
|
"/project/includes",
|
||||||
"-I",
|
"-I",
|
||||||
@@ -507,6 +513,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrderWithoutProjectPartArtifact)
|
|||||||
"-std=c++14",
|
"-std=c++14",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdlibinc",
|
"-nostdlibinc",
|
||||||
|
"-DBAR=1",
|
||||||
|
"-DFOO=1",
|
||||||
"-I",
|
"-I",
|
||||||
"/project/includes",
|
"/project/includes",
|
||||||
"-I",
|
"-I",
|
||||||
@@ -557,6 +565,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrderWithProjectPartArtifact)
|
|||||||
"-std=c++14",
|
"-std=c++14",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdlibinc",
|
"-nostdlibinc",
|
||||||
|
"-DBAR=1",
|
||||||
|
"-DFOO=1",
|
||||||
"-I",
|
"-I",
|
||||||
"/project/includes",
|
"/project/includes",
|
||||||
"-I",
|
"-I",
|
||||||
@@ -611,6 +621,8 @@ TEST_F(SymbolIndexer, UpdateChangedPathCallsInOrder)
|
|||||||
"-std=c++14",
|
"-std=c++14",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdlibinc",
|
"-nostdlibinc",
|
||||||
|
"-DBAR=1",
|
||||||
|
"-DFOO=1",
|
||||||
"-I",
|
"-I",
|
||||||
"/project/includes",
|
"/project/includes",
|
||||||
"-I",
|
"-I",
|
||||||
@@ -671,6 +683,8 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsUsingPrecompiledHeader)
|
|||||||
"-std=c++14",
|
"-std=c++14",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdlibinc",
|
"-nostdlibinc",
|
||||||
|
"-DBAR=1",
|
||||||
|
"-DFOO=1",
|
||||||
"-I",
|
"-I",
|
||||||
"/project/includes",
|
"/project/includes",
|
||||||
"-I",
|
"-I",
|
||||||
@@ -704,6 +718,8 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsNotUsingPrecompiledHeaderIfItNotExists)
|
|||||||
"-std=c++14",
|
"-std=c++14",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdlibinc",
|
"-nostdlibinc",
|
||||||
|
"-DBAR=1",
|
||||||
|
"-DFOO=1",
|
||||||
"-I",
|
"-I",
|
||||||
"/project/includes",
|
"/project/includes",
|
||||||
"-I",
|
"-I",
|
||||||
|
Reference in New Issue
Block a user