]> granicus.if.org Git - clang/commitdiff
[analyzer] Handle ObjC messages conservatively in CallDescription
authorGabor Horvath <xazax.hun@gmail.com>
Mon, 30 Oct 2017 08:47:13 +0000 (08:47 +0000)
committerGabor Horvath <xazax.hun@gmail.com>
Mon, 30 Oct 2017 08:47:13 +0000 (08:47 +0000)
Differential Revision: https://reviews.llvm.org/D37470

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316885 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/CallEvent.cpp
test/Analysis/block-in-critical-section.m [new file with mode: 0644]

index f0a817616dbc27829c87a11a8d17677ec65f76f1..776369be9dbaa874364718921617f3d6cc7a0c87 100644 (file)
@@ -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 (file)
index 0000000..c04a0af
--- /dev/null
@@ -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];
+}