diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-08-10 22:26:43 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-10 22:26:43 +0000 |
commit | 51bcb226a2745d6a7416b30bc2cf54ed4b6c2209 (patch) | |
tree | e5de788f1e83bc6630ab608d19c6ba98c4c7eacd /clang/test/Analysis/inline.cpp | |
parent | 13937b1d7a730111b61355b74674a42f8901c2f5 (diff) | |
download | bcm5719-llvm-51bcb226a2745d6a7416b30bc2cf54ed4b6c2209.tar.gz bcm5719-llvm-51bcb226a2745d6a7416b30bc2cf54ed4b6c2209.zip |
[analyzer] Try to devirtualize even if the static callee has no definition.
This mostly affects pure virtual methods, but would also affect parent
methods defined inline in the header when analyzing the child's source file.
llvm-svn: 161709
Diffstat (limited to 'clang/test/Analysis/inline.cpp')
-rw-r--r-- | clang/test/Analysis/inline.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/test/Analysis/inline.cpp b/clang/test/Analysis/inline.cpp index d16eeaf619b..4298e1aac82 100644 --- a/clang/test/Analysis/inline.cpp +++ b/clang/test/Analysis/inline.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -verify %s void clang_analyzer_eval(bool); +void clang_analyzer_checkInlined(bool); class A { public: @@ -43,3 +44,30 @@ void testPathSensitivity(int x) { clang_analyzer_eval(ptr->getNum() == x); // expected-warning {{TRUE}} } + +namespace PureVirtualParent { + class Parent { + public: + virtual int pureVirtual() const = 0; + int callVirtual() const { + return pureVirtual(); + } + }; + + class Child : public Parent { + public: + virtual int pureVirtual() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return 42; + } + }; + + void testVirtual() { + Child x; + + clang_analyzer_eval(x.pureVirtual() == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(x.callVirtual() == 42); // expected-warning{{TRUE}} + } +} + + |