diff options
| author | Anna Zaks <ganna@apple.com> | 2012-07-30 20:31:18 +0000 |
|---|---|---|
| committer | Anna Zaks <ganna@apple.com> | 2012-07-30 20:31:18 +0000 |
| commit | e49190984c060d288d862a3c340a7fb656fdc5f7 (patch) | |
| tree | 275c11a459f394b9b0e561f23912efa138786666 | |
| parent | 91244268d7e2b496c25300a4c935657380132b59 (diff) | |
| download | bcm5719-llvm-e49190984c060d288d862a3c340a7fb656fdc5f7.tar.gz bcm5719-llvm-e49190984c060d288d862a3c340a7fb656fdc5f7.zip | |
[analyzer] Add -analyzer-ipa=dynamic option for inlining dynamically
dispatched methods.
Disabled by default for now.
llvm-svn: 160988
3 files changed, 24 insertions, 2 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h index 32ff02527d2..26e1cdbdc82 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h @@ -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(); diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index cbd5ea7553d..5e9f3f30893 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -318,6 +318,8 @@ bool ExprEngine::inlineCall(const CallEvent &Call, break; } case CE_ObjCMessage: + if (getAnalysisManager().IPAMode != DynamicDispatch) + return false; break; } diff --git a/clang/test/Analysis/inlining/InlineObjCClassMethod.m b/clang/test/Analysis/inlining/InlineObjCClassMethod.m index 3bd06ebaab3..a5a1369bfe5 100644 --- a/clang/test/Analysis/inlining/InlineObjCClassMethod.m +++ b/clang/test/Analysis/inlining/InlineObjCClassMethod.m @@ -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 |

