From: Gabor Horvath Date: Mon, 30 Oct 2017 08:47:13 +0000 (+0000) Subject: [analyzer] Handle ObjC messages conservatively in CallDescription X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ad457f76010c2f1ffe14f8324410d5ef4c8a8c2;p=clang [analyzer] Handle ObjC messages conservatively in CallDescription Differential Revision: https://reviews.llvm.org/D37470 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316885 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/CallEvent.cpp b/lib/StaticAnalyzer/Core/CallEvent.cpp index f0a817616d..776369be9d 100644 --- a/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -211,7 +211,9 @@ ProgramPoint CallEvent::getProgramPoint(bool IsPreVisit, } bool CallEvent::isCalled(const CallDescription &CD) const { - assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported"); + // FIXME: Add ObjC Message support. + if (getKind() == CE_ObjCMessage) + return false; if (!CD.IsLookupDone) { CD.IsLookupDone = true; CD.II = &getState()->getStateManager().getContext().Idents.get(CD.FuncName); diff --git a/test/Analysis/block-in-critical-section.m b/test/Analysis/block-in-critical-section.m new file mode 100644 index 0000000000..c04a0afb2a --- /dev/null +++ b/test/Analysis/block-in-critical-section.m @@ -0,0 +1,9 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.BlockInCriticalSection -verify -Wno-objc-root-class %s + +@interface SomeClass +-(void)someMethod; +@end + +void shouldNotCrash(SomeClass *o) { + [o someMethod]; +}