diff --git a/plugins/cpp/parser/src/cppparser.cpp b/plugins/cpp/parser/src/cppparser.cpp index 5e2060d5c..3730cbdcc 100644 --- a/plugins/cpp/parser/src/cppparser.cpp +++ b/plugins/cpp/parser/src/cppparser.cpp @@ -748,20 +748,16 @@ bool CppParser::parseByJson( //--- Read the compilation commands compile database ---// - std::vector tempCompileCommands = + std::vector compileCommands = compDb->getAllCompileCommands(); - std::vector compileCommands; - const std::vector 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(); - }); + compileCommands.erase( + std::remove_if(compileCommands.begin(), compileCommands.end(), + [&](const clang::tooling::CompileCommand& c) + { + return !isSourceFile(c.Filename); + }), + compileCommands.end()); std::size_t numCompileCommands = compileCommands.size();