diff options
author | Anna Zaks <ganna@apple.com> | 2012-04-10 21:29:03 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-04-10 21:29:03 +0000 |
commit | a2c8d2edfff1573450c6feba876830dd746ffaad (patch) | |
tree | fc34542f4580fc54138fc40f970e1cfee0a2befd /test/Analysis/dynamic-cast.cpp | |
parent | 15f4c9819d172139c0b37e8a68767ea4fc03e5b6 (diff) |
[analyzer] dynamic_cast: Better model cast from a reference.
Generate a sink when the dynamic_cast from a reference fails to
represent a thrown exception.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154438 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/dynamic-cast.cpp')
-rw-r--r-- | test/Analysis/dynamic-cast.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/Analysis/dynamic-cast.cpp b/test/Analysis/dynamic-cast.cpp index 0d0c80fc12..8d1fde8cc5 100644 --- a/test/Analysis/dynamic-cast.cpp +++ b/test/Analysis/dynamic-cast.cpp @@ -167,10 +167,18 @@ int testCastToVoidStar() { return *res; // no warning } -int testReference() { +int testReferenceSuccesfulCast() { + B rb; + B &b = dynamic_cast<B&>(rb); + int *x = 0; + return *x; // expected-warning {{Dereference of null pointer}} +} + +int testReferenceFailedCast() { A a; B &b = dynamic_cast<B&>(a); - return b.m; // no warning + int *x = 0; + return *x; // no warning (An exception is thrown by the cast.) } // False negatives. |