Skip to content
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

Ignore dependency commands #76

Closed
wants to merge 2 commits into from

Conversation

chrta
Copy link
Contributor

@chrta chrta commented Jul 15, 2013

When creating the json compilation database using "bear make ..." and the makefile generates dependency files, there may be duplicate entries in the variable compileCommands in constructCompileCommands(), one entry for the dependency file generation, one entry for the actual compilation.

This patch filters the commands that contain "-M" or "-MM". The will be ignored.

@lqi
Copy link
Contributor

lqi commented Jul 16, 2013

This is a valid point, separated entries for generating dependencies and compilation cause duplicated violations. However, at the same time, it's very common for Objective-C projects have things like -MMD -MF main.dep -c foo.cpp -o foo.o in the compile_command.json, The second example generates dependencies and compiled object along the way.

I was wondering if this should be a fix on Bear side. Keeping this track requires us taking more scenarios into consideration.

Or another idea might be adding a filter to Results, where it removes duplicated violations existing in different ViolationSets.

Look forward to your opinions.

@chrta
Copy link
Contributor Author

chrta commented Jul 16, 2013

Ignore Dependency Commands

I don't know if bear should do this. In my opinion dependency file generation is only to aid the build tool (like make) to get the dependencies right. It has no influence on the created AST. So commands that only do dependency file generation (without compilation) need not be part of compile_command.json.

Remove Duplications

As mentioned here: http://clang.llvm.org/docs/JSONCompilationDatabase.html:

There can be multiple command objects for the same file, for example if the same source file is compiled with different configurations.

So we should remove duplicated violations. This would also allow to check various build configurations in one oclint run (e.g. like cppcheck does).

@lqi
Copy link
Contributor

lqi commented Jul 17, 2013

For this case, I agree with removing duplication for reporting purposes. New issue #80 created. Sincerely thank you for this great pull request. It could eventually make two projects better.

@lqi lqi closed this Jul 17, 2013
@chrta chrta deleted the ignore-dependency-commands branch January 24, 2014 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants