[clang] [analyzer] Splitting TaintPropagation checker into reporting and mode… (PR #98157)

Donát Nagy via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 9 09:17:36 PDT 2024


================
@@ -1122,10 +1131,20 @@ void GenericTaintChecker::taintUnsafeSocketProtocol(const CallEvent &Call,
 }
 
 /// Checker registration
-void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+void ento::registerTaintPropagationChecker(CheckerManager &Mgr) {
   Mgr.registerChecker<GenericTaintChecker>();
 }
 
+bool ento::shouldRegisterTaintPropagationChecker(const CheckerManager &mgr) {
+  return true;
+}
+
+void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+  GenericTaintChecker *checker = Mgr.getChecker<GenericTaintChecker>();
+  checker->isTaintReporterCheckerEnabled = true;
+  checker->reporterCheckerName = Mgr.getCurrentCheckerName();
----------------
NagyDonat wrote:

Move the initialization of `BT` to this point -- then it doesn't need to be a `mutable` and you won't need the string data member `reporterCheckerName`.

Notes:
- You may turn `BT` into a public data member -- its visibility is still limited to this one source file. 
- `BugType` is a very simple type (essentially a plain struct of three strings), there is no reason to postpone its initialization once you have all the data.
- You can use `BugType::getCheckerName()` to get the checker name to construct the `CheckerProgramPointTag`.

https://github.com/llvm/llvm-project/pull/98157


More information about the cfe-commits mailing list