summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/dynamic-cast.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-14 21:14:41 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-14 21:14:41 +0000
commitfa8b4955bbdbf16d353eea56bf7f3362f6c85caa (patch)
tree8124b19855dab994fca52adab168afe5800b89b2 /clang/test/CodeGenCXX/dynamic-cast.cpp
parent95f6ebcb37fe5d24f80752881509098c3fdf7b48 (diff)
downloadbcm5719-llvm-fa8b4955bbdbf16d353eea56bf7f3362f6c85caa.tar.gz
bcm5719-llvm-fa8b4955bbdbf16d353eea56bf7f3362f6c85caa.zip
When a failed dynamic_cast<T&> (which is an lvalue) results in a
throw, it should use invoke when needed. The fixes the Boost.Statechrt failures that motivated PR7132, but there are a few side issues to tackle as well. llvm-svn: 103803
Diffstat (limited to 'clang/test/CodeGenCXX/dynamic-cast.cpp')
-rw-r--r--clang/test/CodeGenCXX/dynamic-cast.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/clang/test/CodeGenCXX/dynamic-cast.cpp b/clang/test/CodeGenCXX/dynamic-cast.cpp
index aeb2a64157b..572b521c925 100644
--- a/clang/test/CodeGenCXX/dynamic-cast.cpp
+++ b/clang/test/CodeGenCXX/dynamic-cast.cpp
@@ -1,8 +1,20 @@
-// RUN: %clang_cc1 %s -emit-llvm-only
-
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -o - | FileCheck %s
+#include <typeinfo>
struct A { virtual void f(); };
struct B : A { };
+// CHECK: {{define.*@_Z1fP1A}}
+B fail;
const B& f(A *a) {
- return dynamic_cast<const B&>(*a);
+ try {
+ // CHECK: call i8* @__dynamic_cast
+ // CHECK: br i1
+ // CHECK: invoke void @__cxa_bad_cast() noreturn
+ return dynamic_cast<const B&>(*a);
+ } catch (std::bad_cast&) {
+ // CHECK: call i8* @llvm.eh.exception
+ // CHECK: {{call.*llvm.eh.selector.*_ZTISt8bad_cast}}
+ // CHECK: {{call i32 @llvm.eh.typeid.for.*@_ZTISt8bad_cast}}
+ }
+ return fail;
}
OpenPOWER on IntegriCloud