cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

Enhancements to --help

Open samopolacek opened this issue 2 years ago • 8 comments

I am a bit confused about the relationship of --project and --max-configs/--force.

It it true that, for compile_commands.json, --max-configs=0 is implied? Multiple configs (Debug, Release, Win32, ...) are checked for Windows?

I would like to use PR as means to understand it better and improve cppcheck --help along the way as I bet that I am not the one confused.

samopolacek avatar Aug 04 '23 10:08 samopolacek

This also needs to be added to the manpage via man/cppcheck.1.xml.

I am not sure if we should pack this all into the command-line. That should probably go into the actual documentation. But I have not dealt with that yet so it should be fine for now.

firewave avatar Aug 04 '23 12:08 firewave

@firewave It it true that, for compile_commands.json, --max-configs=0 is implied? I.e. no other configs other than what is exactly in the database is checked? But, for Windows, and it's .sln or .vcxproj, multiple configs (Debug, Release, Win32, ...) are checked if not otherwise specified with --project-configuration?

samopolacek avatar Aug 06 '23 07:08 samopolacek

No idea. I only ever used compilation databases as input. I still have tests sitting in my tree which uses the other inputs for our code base but I only specified the commands to run them and never really looked into them so far as they would (unnecessarily) increase the CI runtime.

Just thinking about it logically compilation databases are the dump of the commands of a certain configuration so those can (and should) only ever check a single config whereas other projects (e.g. Visual Studio projects) might have more configs to choose from.

firewave avatar Aug 06 '23 15:08 firewave

It it true that, for compile_commands.json, --max-configs=0 is implied?

I am not 100% sure.

However it is likely that the compile_commands.json defines some preprocessor macros and then only 1 configuration is checked. But if it doesn't specify and preprocessor macros then I have the feeling it checks all configurations but I am not sure.

danmar avatar Aug 07 '23 11:08 danmar

@danmar It would be good to document the behavior and also to make sure that it is not random, e.g. if compile_commands.json has at least one preprocessor macro and if that implies that no other configs are checked, the same should be true if compile_commands.json has no preprocessor macros at all, and that should be enforced by a piece of code with a comment. Are you willing to have a look at that? Maybe figure out what the current behavior is and possibly push a commit into this PR that would enforce the "no additional configs checked even if there is zero preprocessor macros in compile_commands.json" behavior.

Edit: I have granted you access to my fork so you will be able to push, if you decide to.

samopolacek avatar Aug 09 '23 07:08 samopolacek

--max-configs=12 has no effect if --project=compile_commands.json is used --force does have an effect if --project=compile_commands.json is used

samopolacek avatar Aug 10 '23 19:08 samopolacek

Somewhat related: https://trac.cppcheck.net/ticket/11824.

CC @chrfranke

firewave avatar Aug 11 '23 12:08 firewave

@samopolacek sorry for late reply.

It would be good to document the behavior and also to make sure that it is not random, e.g. if compile_commands.json has at least one preprocessor macro and if that implies that no other configs are checked, the same should be true if compile_commands.json has no preprocessor macros at all, and that should be enforced by a piece of code with a comment. Are you willing to have a look at that?

I agree.

danmar avatar Aug 29 '23 20:08 danmar