diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/contrib/llvm-project/clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp b/contrib/llvm-project/clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp index 13985af76b00..4937af3b91c2 100644 --- a/contrib/llvm-project/clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp +++ b/contrib/llvm-project/clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp @@ -30,12 +30,7 @@ namespace { class ObjCContainersChecker : public Checker< check::PreStmt<CallExpr>, check::PostStmt<CallExpr>, check::PointerEscape> { - mutable std::unique_ptr<BugType> BT; - inline void initBugType() const { - if (!BT) - BT.reset(new BugType(this, "CFArray API", - categories::CoreFoundationObjectiveC)); - } + const BugType BT{this, "CFArray API", categories::CoreFoundationObjectiveC}; inline SymbolRef getArraySym(const Expr *E, CheckerContext &C) const { SVal ArrayRef = C.getSVal(E); @@ -47,9 +42,6 @@ class ObjCContainersChecker : public Checker< check::PreStmt<CallExpr>, CheckerContext &C) const; public: - /// A tag to id this checker. - static void *getTag() { static int Tag; return &Tag; } - void checkPostStmt(const CallExpr *CE, CheckerContext &C) const; void checkPreStmt(const CallExpr *CE, CheckerContext &C) const; ProgramStateRef checkPointerEscape(ProgramStateRef State, @@ -90,7 +82,7 @@ void ObjCContainersChecker::checkPostStmt(const CallExpr *CE, return; // Add array size information to the state. - if (Name.equals("CFArrayCreate")) { + if (Name == "CFArrayCreate") { if (CE->getNumArgs() < 3) return; // Note, we can visit the Create method in the post-visit because @@ -100,7 +92,7 @@ void ObjCContainersChecker::checkPostStmt(const CallExpr *CE, return; } - if (Name.equals("CFArrayGetCount")) { + if (Name == "CFArrayGetCount") { addSizeInfo(CE->getArg(0), CE, C); return; } @@ -113,7 +105,7 @@ void ObjCContainersChecker::checkPreStmt(const CallExpr *CE, return; // Check the array access. - if (Name.equals("CFArrayGetValueAtIndex")) { + if (Name == "CFArrayGetValueAtIndex") { ProgramStateRef State = C.getState(); // Retrieve the size. // Find out if we saw this array symbol before and have information about @@ -137,15 +129,15 @@ void ObjCContainersChecker::checkPreStmt(const CallExpr *CE, // Now, check if 'Idx in [0, Size-1]'. const QualType T = IdxExpr->getType(); - ProgramStateRef StInBound = State->assumeInBound(Idx, *Size, true, T); - ProgramStateRef StOutBound = State->assumeInBound(Idx, *Size, false, T); + ProgramStateRef StInBound, StOutBound; + std::tie(StInBound, StOutBound) = State->assumeInBoundDual(Idx, *Size, T); if (StOutBound && !StInBound) { ExplodedNode *N = C.generateErrorNode(StOutBound); if (!N) return; - initBugType(); + auto R = std::make_unique<PathSensitiveBugReport>( - *BT, "Index is out of bounds", N); + BT, "Index is out of bounds", N); R->addRange(IdxExpr->getSourceRange()); bugreporter::trackExpressionValue(N, IdxExpr, *R, {bugreporter::TrackingKind::Thorough, |