-
Notifications
You must be signed in to change notification settings - Fork 113
Filter C/C++ compile commands #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
plugins/cpp/parser/src/cppparser.cpp
Outdated
| const std::vector<std::string> cppExts{ | ||
| ".c", ".cc", ".cpp", ".cxx", ".o", ".so", ".a"}; |
There was a problem hiding this comment.
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
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(), |
There was a problem hiding this comment.
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.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| std::back_inserter(compileCommands), [&](clang::tooling::CompileCommand c) | |
| std::back_inserter(compileCommands), [&](const clang::tooling::CompileCommand& c) |
|
Thanks @bruntib, I committed all changes you requested. |
Filter compile commands from
compile_commands.jsonso C++ plugin won't try to parse everything in case of a multi-language project.