-
Notifications
You must be signed in to change notification settings - Fork 15.8k
[NFC][analyzer] Multipart checker refactor 2: NullabilityChecker #132250
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d4878a6
[NFC][analyzer] Multipart checker refactor 2: NullabilityChecker
NagyDonat 2708bed
Remove hidden dummy checker part NullabilityBase
NagyDonat 3ca23ce
Use `BugType` parameters for `reportBug{,IfInvariantHolds}`
NagyDonat d490c74
Special case NoDiagnoseCallsToSystemHeaders as group-level option
NagyDonat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1403,6 +1403,16 @@ void NullabilityChecker::printState(raw_ostream &Out, ProgramStateRef State, | |
| } | ||
| } | ||
|
|
||
| // The checker group "nullability" consists of the checkers that are | ||
| // implemented as the parts of the checker class `NullabilityChecker`. These | ||
| // checkers share a checker option "nullability:NoDiagnoseCallsToSystemHeaders" | ||
| // which semantically belongs to the whole group and not just one checker from | ||
| // it. As this is a unique situation (I don't know about any other similar | ||
| // group-level option) there is no mechanism to inject this group name from | ||
| // e.g. Checkers.td, so I'm just hardcoding it here. (These are old stable | ||
| // checkers, I don't think that their name will change.) | ||
| #define CHECKER_GROUP_NAME "nullability" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use a static constexpr StringLiteral instead.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's probably a better choice. |
||
|
|
||
| #define REGISTER_CHECKER(Part, TrackingRequired) \ | ||
| void ento::register##Part##Checker(CheckerManager &Mgr) { \ | ||
| auto *Checker = Mgr.registerChecker<NullabilityChecker, \ | ||
|
|
@@ -1411,8 +1421,7 @@ void NullabilityChecker::printState(raw_ostream &Out, ProgramStateRef State, | |
| Checker->NoDiagnoseCallsToSystemHeaders = \ | ||
| Checker->NoDiagnoseCallsToSystemHeaders || \ | ||
| Mgr.getAnalyzerOptions().getCheckerBooleanOption( \ | ||
| Mgr.getCurrentCheckerName(), "NoDiagnoseCallsToSystemHeaders", \ | ||
| true); \ | ||
| CHECKER_GROUP_NAME, "NoDiagnoseCallsToSystemHeaders", true); \ | ||
| } \ | ||
| \ | ||
| bool ento::shouldRegister##Part##Checker(const CheckerManager &) { \ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this PR, the registration functions of the (real) checker parts actually tested the presence of the checker option
nullability.NullabilityBase:NoDiagnoseCallsToSystemHeaders, wherenullability.NullabilityBasewas the hidden dummy checker part that was added as a prerequisite of all the "real" checker parts. (Note that -- ironically --registerNullabilityBase()did not check for the presence of this option which was nominally attached to it.)This was working because in the checker option handling code specifying an option on the group level (e.g. saying
nullability:NoDiagnoseCallsToSystemHeaders=true) is roughly equivalent to passing it to every checker within the group.In commit d490c74 I'm turning this option into a "real" group-level option by passing the group name to
getCheckerBooleanOption.By the way the name of this option is really ugly -- it should be
DiagnoseCallsToSystemHeaderswith negated meaning -- but that's a problem for another commit.