Skip to content

Commit

Permalink
Filter C/C++ compile commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
intjftw committed Feb 3, 2022
1 parent d2fc74e commit 75d3220
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion plugins/cpp/parser/src/cppparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,21 @@ bool CppParser::parseByJson(

//--- Read the compilation commands compile database ---//

std::vector<clang::tooling::CompileCommand> compileCommands =
std::vector<clang::tooling::CompileCommand> tempCompileCommands =
compDb->getAllCompileCommands();
std::vector<clang::tooling::CompileCommand> compileCommands;

const std::vector<std::string> cppExts{
".c", ".cc", ".cpp", ".cxx", ".o", ".so", ".a"};

std::copy_if(tempCompileCommands.begin(), tempCompileCommands.end(),
std::back_inserter(compileCommands), [&](clang::tooling::CompileCommand c)
{
auto iter = std::find(cppExts.begin(), cppExts.end(),
fs::extension(c.Filename));
return iter != cppExts.end();
});

std::size_t numCompileCommands = compileCommands.size();

//--- Create a thread pool for the current commands ---//
Expand Down

0 comments on commit 75d3220

Please sign in to comment.