[cfe-commits] r161059 - in /cfe/trunk: lib/StaticAnalyzer/Core/CallEvent.cpp test/Analysis/inlining/InlineObjCInstanceMethod.m
Jordan Rose
jordan_rose at apple.com
Tue Jul 31 11:04:53 PDT 2012
Author: jrose
Date: Tue Jul 31 13:04:53 2012
New Revision: 161059
URL: http://llvm.org/viewvc/llvm-project?rev=161059&view=rev
Log:
[analyzer] Don't try to inline if there's no region for a message receiver.
While usually we'd use a symbolic region rather than a straight-up Unknown,
we can still generate unknowns via array subscripts with symbolic indexes.
(And if this ever changes in the future, we still shouldn't crash.)
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=161059&r1=161058&r2=161059&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Tue Jul 31 13:04:53 2012
@@ -681,6 +681,9 @@
ReceiverT = cast<ObjCObjectPointerType>(SupersType.getTypePtr());
} else {
const MemRegion *Receiver = getReceiverSVal().getAsRegion();
+ if (!Receiver)
+ return 0;
+
DynamicTypeInfo TI = getState()->getDynamicTypeInfo(Receiver);
ReceiverT = dyn_cast<ObjCObjectPointerType>(TI.getType().getTypePtr());
}
Modified: cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m?rev=161059&r1=161058&r2=161059&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m (original)
+++ cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m Tue Jul 31 13:04:53 2012
@@ -77,4 +77,10 @@
- (int) method2 {
return 5/_attribute; // expected-warning {{Division by zero}}
}
- at end
\ No newline at end of file
+ at end
+
+
+// Don't crash if we don't know the receiver's region.
+void randomlyMessageAnObject(MyClass *arr[], int i) {
+ (void)[arr[i] getInt];
+}
\ No newline at end of file
More information about the cfe-commits
mailing list