diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index 3b9e1e1979a4..fb00a226a210 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -681,6 +681,9 @@ const Decl *ObjCMethodCall::getRuntimeDefinition() const { ReceiverT = cast(SupersType.getTypePtr()); } else { const MemRegion *Receiver = getReceiverSVal().getAsRegion(); + if (!Receiver) + return 0; + DynamicTypeInfo TI = getState()->getDynamicTypeInfo(Receiver); ReceiverT = dyn_cast(TI.getType().getTypePtr()); } diff --git a/clang/test/Analysis/inlining/InlineObjCInstanceMethod.m b/clang/test/Analysis/inlining/InlineObjCInstanceMethod.m index 682d02aa1545..8d8f28d923fe 100644 --- a/clang/test/Analysis/inlining/InlineObjCInstanceMethod.m +++ b/clang/test/Analysis/inlining/InlineObjCInstanceMethod.m @@ -77,4 +77,10 @@ - (int) method2 { return 5/_attribute; // expected-warning {{Division by zero}} } -@end \ No newline at end of file +@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