Skip to content

Conversation

@intjftw
Copy link
Collaborator

@intjftw intjftw commented Feb 3, 2022

Filter compile commands from compile_commands.json so C++ plugin won't try to parse everything in case of a multi-language project.

@intjftw intjftw added Kind: Enhancement 🌟 Plugin: C++ Issues related to the parsing and presentation of C++ projects. labels Feb 3, 2022
@intjftw intjftw added this to the Release Gershwin milestone Feb 3, 2022
@intjftw intjftw requested review from bruntib and mcserep February 3, 2022 15:28
Comment on lines 755 to 756
const std::vector<std::string> cppExts{
".c", ".cc", ".cpp", ".cxx", ".o", ".so", ".a"};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a function already which checks whether a file is a cpp file:
https://github.com/Ericsson/CodeCompass/blob/master/plugins/cpp/parser/src/cppparser.cpp#L157-L166

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

std::copy_if(tempCompileCommands.begin(), tempCompileCommands.end(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove elements with remove_if or something similar in order to avoid a copy of the compile commands.

".c", ".cc", ".cpp", ".cxx", ".o", ".so", ".a"};

std::copy_if(tempCompileCommands.begin(), tempCompileCommands.end(),
std::back_inserter(compileCommands), [&](clang::tooling::CompileCommand c)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::back_inserter(compileCommands), [&](clang::tooling::CompileCommand c)
std::back_inserter(compileCommands), [&](const clang::tooling::CompileCommand& c)

@intjftw intjftw requested a review from bruntib February 16, 2022 11:55
@intjftw
Copy link
Collaborator Author

intjftw commented Feb 16, 2022

Thanks @bruntib, I committed all changes you requested.

@intjftw intjftw merged commit 5e1c7a0 into Ericsson:master Feb 21, 2022
@intjftw intjftw deleted the filter-cpp-compile-commands branch February 21, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Kind: Enhancement 🌟 Plugin: C++ Issues related to the parsing and presentation of C++ projects.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants