diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-10-16 00:47:25 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-10-16 00:47:25 +0000 |
commit | bc9e5ffb0d0757238c071764e4bc1fc8a1521097 (patch) | |
tree | 22575e46d48b80ee1594e593343ea57e36ee532d /lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp | |
parent | 81765577dbf740c7cef1edfe59661c95408fa85b (diff) |
[analyzer] ObjCContainersASTChecker: minor cleanup and an extra test case.
Follow-up to r165838, which fixed a potential crash.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp index 9c0c3cd3b6..63a84805e7 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp @@ -31,8 +31,6 @@ class WalkAST : public StmtVisitor<WalkAST> { ASTContext &ASTC; uint64_t PtrWidth; - static const unsigned InvalidArgIndex = UINT_MAX; - /// Check if the type has pointer size (very conservative). inline bool isPointerSize(const Type *T) { if (!T) @@ -102,7 +100,7 @@ void WalkAST::VisitCallExpr(CallExpr *CE) { return; const Expr *Arg = 0; - unsigned ArgNum = InvalidArgIndex; + unsigned ArgNum; if (Name.equals("CFArrayCreate") || Name.equals("CFSetCreate")) { if (CE->getNumArgs() != 4) @@ -111,9 +109,7 @@ void WalkAST::VisitCallExpr(CallExpr *CE) { Arg = CE->getArg(ArgNum)->IgnoreParenCasts(); if (hasPointerToPointerSizedType(Arg)) return; - } - - if (Arg == 0 && Name.equals("CFDictionaryCreate")) { + } else if (Name.equals("CFDictionaryCreate")) { if (CE->getNumArgs() != 6) return; // Check first argument. @@ -129,13 +125,11 @@ void WalkAST::VisitCallExpr(CallExpr *CE) { } } - if (ArgNum != InvalidArgIndex) { + if (Arg) { assert(ArgNum == 1 || ArgNum == 2); - assert(Arg); - SmallString<256> BufName; + SmallString<64> BufName; llvm::raw_svector_ostream OsName(BufName); - assert(ArgNum == 1 || ArgNum == 2); OsName << " Invalid use of '" << Name << "'" ; SmallString<256> Buf; |