[cfe-commits] r160988 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp test/Analysis/inlining/InlineObjCClassMethod.m

Anna Zaks ganna at apple.com
Mon Jul 30 13:31:18 PDT 2012


Author: zaks
Date: Mon Jul 30 15:31:18 2012
New Revision: 160988

URL: http://llvm.org/viewvc/llvm-project?rev=160988&view=rev
Log:
[analyzer] Add -analyzer-ipa=dynamic option for inlining dynamically
dispatched methods.

Disabled by default for now.

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

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h?rev=160988&r1=160987&r2=160988&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h Mon Jul 30 15:31:18 2012
@@ -169,7 +169,7 @@
 
   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();

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=160988&r1=160987&r2=160988&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Mon Jul 30 15:31:18 2012
@@ -318,6 +318,8 @@
     break;
   }
   case CE_ObjCMessage:
+    if (getAnalysisManager().IPAMode != DynamicDispatch)
+      return false;
     break;
   }
 

Modified: cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m?rev=160988&r1=160987&r2=160988&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m (original)
+++ cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m Mon Jul 30 15:31:18 2012
@@ -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 @@
 }
 @end
 
+// ObjC class method is called by name. Definition is in the parent category.
+ at interface PPP : NSObject
+ at end
+ at interface PPP (MyCat)
++ (int)getInt;
+ at end
+ at interface CCC : PPP
+ at end
+int foo4() {
+    int y = [CCC getInt];
+    return 5/y; // expected-warning {{Division by zero}}
+}
+ at implementation PPP
+ at end
+ at implementation PPP (MyCat)
++ (int)getInt {
+    return 0;
+}
+ at 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





More information about the cfe-commits mailing list