Skip to content

Commit 0d8e16a

Browse files
authored
[analyzer][NFC] Make CheckerDocumentation checker in-sync with actual checker callbacks (#83973)
In PR #83677 I was surprised to see that outdated checker callback signatures are a problem. It turns out, we need the `registerChecker...` function to invoke the `Mgr.registerChecker<>()` which would instantiate the `_register` calls, that would take the address of the defined checker callbacks. Consequently, if the expected signatures mismatch, it won't compile from now on, so we have static guarantee that this issue never pops up again. Given we need the `register` call, at this point we could just hook this checker into the `debug` package and make it never registered. It shouldn't hurt anyone :)
1 parent a642eb8 commit 0d8e16a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,10 @@ def StdCLibraryFunctionsTesterChecker : Checker<"StdCLibraryFunctionsTester">,
16541654
WeakDependencies<[StdCLibraryFunctionsChecker]>,
16551655
Documentation<NotDocumented>;
16561656

1657+
def CheckerDocumentationChecker : Checker<"CheckerDocumentation">,
1658+
HelpText<"Defines an empty checker callback for all possible handlers.">,
1659+
Documentation<NotDocumented>;
1660+
16571661
} // end "debug"
16581662

16591663

clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ class CheckerDocumentation : public Checker< check::PreStmt<ReturnStmt>,
137137
/// (2) and (3). Post-call for the allocator is called after step (1).
138138
/// Pre-statement for the new-expression is called on step (4) when the value
139139
/// of the expression is evaluated.
140-
/// \param NE The C++ new-expression that triggered the allocation.
141-
/// \param Target The allocated region, casted to the class type.
142-
void checkNewAllocator(const CXXNewExpr *NE, SVal Target,
143-
CheckerContext &) const {}
140+
void checkNewAllocator(const CXXAllocatorCall &, CheckerContext &) const {}
144141

145142
/// Called on a load from and a store to a location.
146143
///
@@ -330,5 +327,13 @@ void CheckerDocumentation::checkPostStmt(const DeclStmt *DS,
330327
CheckerContext &C) const {
331328
}
332329

330+
void registerCheckerDocumentationChecker(CheckerManager &Mgr) {
331+
Mgr.registerChecker<CheckerDocumentation>();
332+
}
333+
334+
bool shouldRegisterCheckerDocumentationChecker(const CheckerManager &) {
335+
return false;
336+
}
337+
333338
} // end namespace ento
334339
} // end namespace clang

0 commit comments

Comments
 (0)