Skip to content

Filter C/C++ compile commands#556

Merged
intjftw merged 2 commits into
Ericsson:masterfrom
mcserep:filter-cpp-compile-commands
Feb 21, 2022
Merged

Filter C/C++ compile commands#556
intjftw merged 2 commits into
Ericsson:masterfrom
mcserep:filter-cpp-compile-commands

Conversation

@intjftw

@intjftw intjftw commented Feb 3, 2022

Copy link
Copy Markdown
Contributor

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 thread plugins/cpp/parser/src/cppparser.cpp Outdated
Comment on lines +755 to +756
const std::vector<std::string> cppExts{
".c", ".cc", ".cpp", ".cxx", ".o", ".so", ".a"};

Copy link
Copy Markdown
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

Comment thread plugins/cpp/parser/src/cppparser.cpp Outdated
const std::vector<std::string> cppExts{
".c", ".cc", ".cpp", ".cxx", ".o", ".so", ".a"};

std::copy_if(tempCompileCommands.begin(), tempCompileCommands.end(),

Copy link
Copy Markdown
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.

Comment thread plugins/cpp/parser/src/cppparser.cpp Outdated
".c", ".cc", ".cpp", ".cxx", ".o", ".so", ".a"};

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

Copy link
Copy Markdown
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

intjftw commented Feb 16, 2022

Copy link
Copy Markdown
Contributor Author

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