]> granicus.if.org Git - clang/commitdiff
[analyzer] Add -analyzer-ipa=dynamic option for inlining dynamically
authorAnna Zaks <ganna@apple.com>
Mon, 30 Jul 2012 20:31:18 +0000 (20:31 +0000)
committerAnna Zaks <ganna@apple.com>
Mon, 30 Jul 2012 20:31:18 +0000 (20:31 +0000)
dispatched methods.

Disabled by default for now.

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

include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
test/Analysis/inlining/InlineObjCClassMethod.m

index 32ff02527d2e9f7f1120361574f4b64a6c02620e..26e1cdbdc8281015053ace8f67f7b743574ed368 100644 (file)
@@ -169,7 +169,7 @@ public:
 
   bool shouldEagerlyAssume() const { return EagerlyAssume; }
 
-  bool shouldInlineCall() const { return (IPAMode == Inlining); }
+  bool shouldInlineCall() const { return (IPAMode != None); }
 
   CFG *getCFG(Decl const *D) {
     return AnaCtxMgr.getContext(D)->getCFG();
index cbd5ea7553d0253082d2c7ca04f933b977ce69bb..5e9f3f3089327377cf76a0323ca1a527cace08af 100644 (file)
@@ -318,6 +318,8 @@ bool ExprEngine::inlineCall(const CallEvent &Call,
     break;
   }
   case CE_ObjCMessage:
+    if (getAnalysisManager().IPAMode != DynamicDispatch)
+      return false;
     break;
   }
 
index 3bd06ebaab3f0f41108af43f71c1d47be2b8184f..a5a1369bfe54e10cee8e60eae96803b334901715 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=dynamic -verify %s
 
 // Test inlining of ObjC class methods.
 
@@ -70,6 +70,26 @@ int foo() {
 }
 @end
 
+// ObjC class method is called by name. Definition is in the parent category.
+@interface PPP : NSObject
+@end
+@interface PPP (MyCat)
++ (int)getInt;
+@end
+@interface CCC : PPP
+@end
+int foo4() {
+    int y = [CCC getInt];
+    return 5/y; // expected-warning {{Division by zero}}
+}
+@implementation PPP
+@end
+@implementation PPP (MyCat)
++ (int)getInt {
+    return 0;
+}
+@end
+
 // There is no declaration in the class but there is one in the parent. Make 
 // sure we pick the definition from the class and not the parent.
 @interface MyParentTricky : NSObject