This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][NFC] Keep track of whether enabling a checker was explictly specified in command line arguments
ClosedPublic

Authored by Szelethus on Jan 20 2019, 4:25 PM.

Details

Summary

One of the bugs that I left in in my dependency patch D54438 was luckily discovered thanks to @george.karpenkov commiting a patch a couple days before I attempted to commit: Namely, the rigid structure of how the user can enable/disable checkers wasn't respected, and chaos ensued when a dependency was disabled, but the checker that was depending on it was enabled.

I added a new enum to CheckerInfo, so we can easily track whether the check is explicitly enabled, explicitly disabled, or isn't specified in this regard. Checkers belonging in the latter category may be implicitly enabled through dependencies in the followup patch. I also made sure that this is done within CheckerRegisty's constructor, leading to very significant simplifications in its query-like methods.

Diff Detail

Repository
rL LLVM

Event Timeline

Szelethus created this revision.Jan 20 2019, 4:25 PM
Szelethus retitled this revision from [analyzer][NFC] Fully initialize CheckerRegistry in by the end of construction, make all methods const to [analyzer][NFC] Fully initialize CheckerRegistry in by the end of construction.Jan 20 2019, 4:25 PM
Szelethus updated this revision to Diff 182724.Jan 20 2019, 4:32 PM

Remove mutable specifiers from all fields of CheckerRegistry.

Szelethus retitled this revision from [analyzer][NFC] Fully initialize CheckerRegistry in by the end of construction to [analyzer][NFC] Keep track of whether enabling a checker was explictly specified in command line arguments.Jan 21 2019, 12:24 AM
Szelethus edited the summary of this revision. (Show Details)
Szelethus set the repository for this revision to rC Clang.
NoQ accepted this revision.Jan 25 2019, 6:34 PM

Cool!

I guess we still need to think how exactly do we want to resolve conflicts between dependencies.

include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
152 ↗(On Diff #182724)

Indeed! And, which is probably even more important, to scan-build's help (assuming that the respective flags of scan-build do actually work in a similar manner).

lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
143 ↗(On Diff #182724)

I learned a new word today :) :)

This revision is now accepted and ready to land.Jan 25 2019, 6:34 PM
Szelethus marked an inline comment as done.Jan 26 2019, 8:34 AM
Szelethus added inline comments.
lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
143 ↗(On Diff #182724)

Wish it came from me, but I just moved it around... put a smile on my face every time I came across it too though :)

This revision was automatically updated to reflect the committed changes.

Oops, I ran into the issue of check-clang-analysis not actually running out unit tests. I decided not to revert this patch and just commit the fix: rC352284. Any objections?