[cfe-commits] r154083 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp test/Analysis/CFContainers.mm
Ted Kremenek
kremenek at apple.com
Wed Apr 4 22:18:05 PDT 2012
Author: kremenek
Date: Thu Apr 5 00:18:05 2012
New Revision: 154083
URL: http://llvm.org/viewvc/llvm-project?rev=154083&view=rev
Log:
Teach ObjCContainersChecker that the array passed to CFArrayGetValueAtIndex might not be a symbolic value.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
cfe/trunk/test/Analysis/CFContainers.mm
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp?rev=154083&r1=154082&r2=154083&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp Thu Apr 5 00:18:05 2012
@@ -40,7 +40,6 @@
inline SymbolRef getArraySym(const Expr *E, CheckerContext &C) const {
SVal ArrayRef = C.getState()->getSVal(E, C.getLocationContext());
SymbolRef ArraySym = ArrayRef.getAsSymbol();
- assert(ArraySym);
return ArraySym;
}
@@ -120,8 +119,12 @@
// Retrieve the size.
// Find out if we saw this array symbol before and have information about it.
const Expr *ArrayExpr = CE->getArg(0);
- const DefinedSVal *Size =
- State->get<ArraySizeMap>(getArraySym(ArrayExpr, C));
+ SymbolRef ArraySym = getArraySym(ArrayExpr, C);
+ if (!ArraySym)
+ return;
+
+ const DefinedSVal *Size = State->get<ArraySizeMap>(ArraySym);
+
if (!Size)
return;
Modified: cfe/trunk/test/Analysis/CFContainers.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFContainers.mm?rev=154083&r1=154082&r2=154083&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/CFContainers.mm (original)
+++ cfe/trunk/test/Analysis/CFContainers.mm Thu Apr 5 00:18:05 2012
@@ -198,3 +198,7 @@
const void *s1 = CFArrayGetValueAtIndex(B, 2);
}
+
+void TestNullArray() {
+ CFArrayGetValueAtIndex(0, 0);
+}
More information about the cfe-commits
mailing list