[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.
llvm-svn: 154438
diff --git a/clang/test/Analysis/dynamic-cast.cpp b/clang/test/Analysis/dynamic-cast.cpp
index 0d0c80f..8d1fde8 100644
--- a/clang/test/Analysis/dynamic-cast.cpp
+++ b/clang/test/Analysis/dynamic-cast.cpp
@@ -167,10 +167,18 @@
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.