Skip to content

Commit

Permalink
[analyzer][NFC] Demonstrate the use of CallDescriptionSet
Browse files Browse the repository at this point in the history
Reviewed By: martong, xazax.hun

Differential Revision: https://reviews.llvm.org/D113592
  • Loading branch information
Balazs Benics committed Nov 19, 2021
1 parent f18da19 commit 9ad0a90
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
Expand Up @@ -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;
Expand All @@ -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.
Expand Down

0 comments on commit 9ad0a90

Please sign in to comment.