Skip to content

Commit 9ad0a90

Browse files
author
Balazs Benics
committed
[analyzer][NFC] Demonstrate the use of CallDescriptionSet
Reviewed By: martong, xazax.hun Differential Revision: https://reviews.llvm.org/D113592
1 parent f18da19 commit 9ad0a90

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,12 @@ void CFNumberChecker::checkPreStmt(const CallExpr *CE,
534534
namespace {
535535
class CFRetainReleaseChecker : public Checker<check::PreCall> {
536536
mutable APIMisuse BT{this, "null passed to CF memory management function"};
537-
CallDescription CFRetain{"CFRetain", 1},
538-
CFRelease{"CFRelease", 1},
539-
CFMakeCollectable{"CFMakeCollectable", 1},
540-
CFAutorelease{"CFAutorelease", 1};
537+
const CallDescriptionSet ModelledCalls = {
538+
{"CFRetain", 1},
539+
{"CFRelease", 1},
540+
{"CFMakeCollectable", 1},
541+
{"CFAutorelease", 1},
542+
};
541543

542544
public:
543545
void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -551,8 +553,7 @@ void CFRetainReleaseChecker::checkPreCall(const CallEvent &Call,
551553
return;
552554

553555
// Check if we called CFRetain/CFRelease/CFMakeCollectable/CFAutorelease.
554-
555-
if (!matchesAny(Call, CFRetain, CFRelease, CFMakeCollectable, CFAutorelease))
556+
if (!ModelledCalls.contains(Call))
556557
return;
557558

558559
// Get the argument's value.

0 commit comments

Comments
 (0)