Skip to content

Commit

Permalink
Skip parsing Objective-C++ files as standard C++.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcserep committed May 14, 2024
1 parent 41fc47c commit bc559ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/cpp/parser/include/cppparser/cppparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class CppParser : public AbstractParser
bool isParsed(const clang::tooling::CompileCommand& command_);
bool isSourceFile(const std::string& file_) const;
bool isNonSourceFlag(const std::string& arg_) const;
bool isObjectiveCpp(const clang::tooling::CompileCommand& command_) const;
bool parseByJson(const std::string& jsonFile_, std::size_t threadNum_);
int parseWorker(const clang::tooling::CompileCommand& command_);

Expand Down
12 changes: 11 additions & 1 deletion plugins/cpp/parser/src/cppparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ bool CppParser::isNonSourceFlag(const std::string& arg_) const
return arg_.find("-Wl,") == 0;
}

bool CppParser::isObjectiveCpp(const clang::tooling::CompileCommand& command_) const
{
for (std::size_t i = 1; i < command_.CommandLine.size(); ++i)
{
if (command_.CommandLine[i - 1] == "-x" && command_.CommandLine[i] == "objective-c++")
return true;
}
return false;
}

std::map<std::string, std::string> CppParser::extractInputOutputs(
const clang::tooling::CompileCommand& command_) const
{
Expand Down Expand Up @@ -755,7 +765,7 @@ bool CppParser::parseByJson(
std::remove_if(compileCommands.begin(), compileCommands.end(),
[&](const clang::tooling::CompileCommand& c)
{
return !isSourceFile(c.Filename);
return !isSourceFile(c.Filename) || isObjectiveCpp(c);
}),
compileCommands.end());

Expand Down

0 comments on commit bc559ab

Please sign in to comment.