[clang] 9ad0a90 - [analyzer][NFC] Demonstrate the use of CallDescriptionSet

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 19 09:32:54 PST 2021


Author: Balazs Benics
Date: 2021-11-19T18:32:13+01:00
New Revision: 9ad0a90baa8ca8067fe65086056fffd083c86796

URL: https://github.com/llvm/llvm-project/commit/9ad0a90baa8ca8067fe65086056fffd083c86796
DIFF: https://github.com/llvm/llvm-project/commit/9ad0a90baa8ca8067fe65086056fffd083c86796.diff

LOG: [analyzer][NFC] Demonstrate the use of CallDescriptionSet

Reviewed By: martong, xazax.hun

Differential Revision: https://reviews.llvm.org/D113592

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
index ebd384a5a5b4..2c210fb6cdb9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -534,10 +534,12 @@ void CFNumberChecker::checkPreStmt(const CallExpr *CE,
 namespace {
 class CFRetainReleaseChecker : public Checker<check::PreCall> {
   mutable APIMisuse BT{this, "null passed to CF memory management function"};
-  CallDescription CFRetain{"CFRetain", 1},
-                  CFRelease{"CFRelease", 1},
-                  CFMakeCollectable{"CFMakeCollectable", 1},
-                  CFAutorelease{"CFAutorelease", 1};
+  const CallDescriptionSet ModelledCalls = {
+      {"CFRetain", 1},
+      {"CFRelease", 1},
+      {"CFMakeCollectable", 1},
+      {"CFAutorelease", 1},
+  };
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -551,8 +553,7 @@ void CFRetainReleaseChecker::checkPreCall(const CallEvent &Call,
     return;
 
   // Check if we called CFRetain/CFRelease/CFMakeCollectable/CFAutorelease.
-
-  if (!matchesAny(Call, CFRetain, CFRelease, CFMakeCollectable, CFAutorelease))
+  if (!ModelledCalls.contains(Call))
     return;
 
   // Get the argument's value.


        


More information about the cfe-commits mailing list