[PATCH] D37470: [analyzer] Handle ObjC messages conservatively in CallDescription

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 27 07:22:09 PDT 2017


xazax.hun updated this revision to Diff 120598.
xazax.hun added a comment.

- Added a separate test case as per Devin's suggestion


https://reviews.llvm.org/D37470

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/block-in-critical-section.m


Index: test/Analysis/block-in-critical-section.m
===================================================================
--- /dev/null
+++ 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
+
+ at interface SomeClass
+-(void)someMethod;
+ at end
+
+void shouldNotCrash(SomeClass *o) {
+  [o someMethod];
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -211,7 +211,9 @@
 }
 
 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37470.120598.patch
Type: text/x-patch
Size: 1013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171027/7a588742/attachment.bin>


More information about the cfe-commits mailing list