Skip to content

Commit 4becdeb

Browse files
steakhalNagyDonat
authored andcommitted
HACK: Smuggle in the checker name into the CheckerFamily class
1 parent 7da3862 commit 4becdeb

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

clang/include/clang/StaticAnalyzer/Core/Checker.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ class CheckerBase : public CheckerFrontend, public CheckerBackend {
526526
public:
527527
/// Attached to nodes created by this checker class when the ExplodedGraph is
528528
/// dumped for debugging.
529-
StringRef getDebugName() const override;
529+
StringRef getDebugName() const final;
530530
};
531531

532532
/// Simple checker classes that implement one frontend (i.e. checker name)
@@ -545,16 +545,22 @@ class Checker : public CheckerBase, public CHECKs... {
545545
/// Checker families (where a single backend class implements multiple related
546546
/// frontends) should derive from this template, specify all the implemented
547547
/// callbacks (i.e. classes like `check::PreStmt` or `eval::Call`) as template
548-
/// arguments of `FamilyChecker` and implement the pure virtual method
549-
/// `StringRef getDebugName()` which is inherited from `ProgramPointTag`
550-
/// and should return a string identifying the class for debugging purposes.
548+
/// arguments of `FamilyChecker`.
551549
template <typename... CHECKs>
552550
class CheckerFamily : public CheckerBackend, public CHECKs... {
553551
public:
554552
template <typename CHECKER>
555553
static void _register(CHECKER *Chk, CheckerManager &Mgr) {
554+
Chk->CheckerBackendName = Mgr.getCurrentCheckerName();
556555
(CHECKs::_register(Chk, Mgr), ...);
557556
}
557+
558+
/// Attached to nodes created by this checker class when the ExplodedGraph is
559+
/// dumped for debugging.
560+
StringRef getDebugName() const final { return CheckerBackendName; }
561+
562+
private:
563+
CheckerNameRef CheckerBackendName;
558564
};
559565

560566
template <typename EVENT>

clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ class DivZeroChecker : public CheckerFamily<check::PreStmt<BinaryOperator>> {
3939
categories::TaintedData};
4040

4141
void checkPreStmt(const BinaryOperator *B, CheckerContext &C) const;
42-
43-
/// Identifies this checker family for debugging purposes.
44-
StringRef getDebugName() const override { return "DivZeroChecker"; }
4542
};
4643
} // end anonymous namespace
4744

clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ class VirtualCallChecker
5454
void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const;
5555
void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
5656

57-
/// Identifies this checker family for debugging purposes.
58-
StringRef getDebugName() const override { return "VirtualCallChecker"; }
59-
6057
private:
6158
void registerCtorDtorCallInState(bool IsBeginFunction,
6259
CheckerContext &C) const;

clang/test/Analysis/ftime-trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
// Finally, each checker call back is also present:
4141
//
42-
// CHECK: "name": "Total Stmt:DivZeroChecker",
42+
// CHECK: "name": "Total Stmt:core.DivideZero",
4343
// CHECK-NEXT: "args": {
4444
// CHECK-NEXT: "count": {{[0-9]+}},
4545
// CHECK-NEXT: "avg ms": {{[0-9]+}}

0 commit comments

Comments
 (0)