Skip to content

Commit 75d3220

Browse files
committed
Filter C/C++ compile commands.
1 parent d2fc74e commit 75d3220

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

plugins/cpp/parser/src/cppparser.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,21 @@ bool CppParser::parseByJson(
748748

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

751-
std::vector<clang::tooling::CompileCommand> compileCommands =
751+
std::vector<clang::tooling::CompileCommand> tempCompileCommands =
752752
compDb->getAllCompileCommands();
753+
std::vector<clang::tooling::CompileCommand> compileCommands;
754+
755+
const std::vector<std::string> cppExts{
756+
".c", ".cc", ".cpp", ".cxx", ".o", ".so", ".a"};
757+
758+
std::copy_if(tempCompileCommands.begin(), tempCompileCommands.end(),
759+
std::back_inserter(compileCommands), [&](clang::tooling::CompileCommand c)
760+
{
761+
auto iter = std::find(cppExts.begin(), cppExts.end(),
762+
fs::extension(c.Filename));
763+
return iter != cppExts.end();
764+
});
765+
753766
std::size_t numCompileCommands = compileCommands.size();
754767

755768
//--- Create a thread pool for the current commands ---//

0 commit comments

Comments
 (0)