Skip to content

Commit 0ebfbf3

Browse files
committed
Skip parsing Objective-C++ files as standard C++.
1 parent 12e6692 commit 0ebfbf3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

plugins/cpp/parser/include/cppparser/cppparser.h

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class CppParser : public AbstractParser
103103
bool isParsed(const clang::tooling::CompileCommand& command_);
104104
bool isSourceFile(const std::string& file_) const;
105105
bool isNonSourceFlag(const std::string& arg_) const;
106+
bool isObjectiveCpp(const clang::tooling::CompileCommand& command_) const;
106107
bool parseByJson(const std::string& jsonFile_, std::size_t threadNum_);
107108
int parseWorker(const clang::tooling::CompileCommand& command_);
108109

plugins/cpp/parser/src/cppparser.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ bool CppParser::isNonSourceFlag(const std::string& arg_) const
170170
return arg_.find("-Wl,") == 0;
171171
}
172172

173+
bool CppParser::isObjectiveCpp(const clang::tooling::CompileCommand& command_) const
174+
{
175+
for (std::size_t i = 1; i < command_.CommandLine.size(); ++i)
176+
{
177+
if (command_.CommandLine[i - 1] == "-x" && command_.CommandLine[i] == "objective-c++")
178+
return true;
179+
}
180+
return false;
181+
}
182+
173183
std::map<std::string, std::string> CppParser::extractInputOutputs(
174184
const clang::tooling::CompileCommand& command_) const
175185
{
@@ -755,7 +765,7 @@ bool CppParser::parseByJson(
755765
std::remove_if(compileCommands.begin(), compileCommands.end(),
756766
[&](const clang::tooling::CompileCommand& c)
757767
{
758-
return !isSourceFile(c.Filename);
768+
return !isSourceFile(c.Filename) || isObjectiveCpp(c);
759769
}),
760770
compileCommands.end());
761771

0 commit comments

Comments
 (0)