[PATCH] D69745: [analyzer] Checker: check::BeginAnalysis

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 06:05:04 PST 2019


Szelethus added a comment.

YES PLEASE. Debug checkers that only dump from `check::EndAnalysis` won't rely on the analysis not actually crashing. Which is ironically exactly when we want to use them.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp:199
+  ///
+  /// This callback should be used to construct the checker's fields.
+  ///
----------------
Hmmm, what use case do you have in mind? Do we actually want this to happen? By the time checkers are constructed, the AST is already built, alongside all the other data structures that will be inspected by the analyzer. Since checkers are constructed once for each clang invocation (not for every `BeginAnalysis` -- `EndAnalysis` cycle), I would imagine that the checker registry functions are more appropriate for such initializations.

I'm only aware of one non-debug checker that uses `EndAnalysis` (maybe `RetailCount`?), that clears some sort of a locally stored map that it shouldn't really have anyways (since checkers are supposed to be stateless), and I struggle to think of a realistic, supported use case for this callback other than debug checkers.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69745/new/

https://reviews.llvm.org/D69745





More information about the cfe-commits mailing list