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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

edwinzrodriguez
Copy link

@edwinzrodriguez edwinzrodriguez commented Sep 5, 2023

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

… expansion

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

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

@Szelethus
Copy link
Collaborator

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

@edwinzrodriguez
Copy link
Author

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'

Copy link
Contributor

@bruntib bruntib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Thanks for the improvement. However, we wouldn't like to go in the direction of extending the interface of CodeChecker analyze. The analyzer configuration options shouldn't be exposed on this interface, because there will always be yet another analyzer option that somebody wants to introduce for CodeChecker analyze. I think these analyzer config options should be provided through --analyzer-config flag.

@edwinzrodriguez
Copy link
Author

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

@bruntib
Copy link
Contributor

bruntib commented Jan 8, 2024

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!

@whisperity whisperity added enhancement 🌟 analyzer 📈 Related to the analyze commands (analysis driver) clang sa 🐉 The Clang Static Analyzer is a source code analysis tool that finds bugs in C-family programs. labels Mar 27, 2024
@whisperity whisperity changed the title [enhancement] Add option to control clangsa header analysis and macro… [analyze] Add option to control Clang SA header analysis and macro expansion Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) clang sa 🐉 The Clang Static Analyzer is a source code analysis tool that finds bugs in C-family programs. enhancement 🌟
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants