codechecker icon indicating copy to clipboard operation
codechecker copied to clipboard

[analyze] Add option to control Clang SA header analysis and macro expansion

Open edwinzrodriguez opened this issue 2 years ago • 5 comments

Added two options

  • --analyze-headers [on|off] (default on) to enable/disable clang SA analysis of headers
  • --expand-macros [on|off] (default on) to enable/disable macro expansion in generated plist

edwinzrodriguez avatar Sep 05 '23 22:09 edwinzrodriguez

I'm proposing this change to reduce analysis time for precommit approval. The project I'd like to apply it to consists of approx 1600 source files and takes 5 1/2 hours to analyze with expand-macros=true and -analyzer-opt-analyze-headers enabled. Not setting those options reduces analysis time to ~30 minutes, which is acceptable for a precommit check

edwinzrodriguez avatar Sep 06 '23 17:09 edwinzrodriguez

Hi!

Sorry for the late response, we definitely appreciate all the help we can get!

We already have an option to pass clang static analyzer flags through CodeChecker via the --saargs option. Wouldn't that be a good solution for you?

The problem I foresee is that CodeChecker is (increasingly) less of wrapper around Clang, and more of a general static analysis driver tool, so creating analyzer specific flags may go contradictory to that. This doesn't mean we make exceptions (just look at all the CTU options that, as of now, specifically target ClangSA), I'm just not immediately sure we want to make one here.

Cheers, Husi

Szelethus avatar Oct 05 '23 10:10 Szelethus

The problem is that codechecker sets -analyzer-opt-analyze-headers and there is no option to clang to turn it off once its passed on the cli. And because it already passes expand-macros=true a subsequent expand-macros=false fails as well with error: error reading 'expand-macros=false'

edwinzrodriguez avatar Oct 10 '23 18:10 edwinzrodriguez

How about just removing '-analyzer-opt-analyze-headers' and 'expand-macros=true' and require people who want it to add those options via --saargs

edwinzrodriguez avatar Oct 11 '23 10:10 edwinzrodriguez

Hi, Sorry for the extreme slow reply. So, I would say, that -analyzer-opt-analyze-headers should be turned on by default, because we wouldn't like to introduce CI-breaking changes for teams that integrated CodeChecker. I can be convinced about expand-macros if it causes massive performance loss, but we turned that on for the GUI functionality which displays these macros. On the other hand I would still vote on using --analyzer-config flag when providing any analyzer config options. Thank you!

bruntib avatar Jan 08 '24 09:01 bruntib