1 // RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -std=c++98 -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -std=c++11 -o - %s | FileCheck %s
4 
~A()5 class A { protected: virtual ~A() {} };
~B()6 class B { protected: virtual ~B() {} };
7 
8 class C : A { char x; };
9 class D : public A { short y; };
10 class E : public A, public B { int z; };
11 class F : public virtual A { long long w; };
12 class G : virtual A { long long w; };
13 
14 class H : public E { int a; };
15 class I : public F { char b; };
16 
17 class J : public H { char q; };
18 class K : public C, public B { char q; };
19 
20 class XA : public A { };
21 class XB : public A { };
22 class XC : public virtual A { };
23 class X : public XA, public XB, public XC { };
24 
test(A * a,B * b)25 void test(A *a, B *b) {
26   volatile C *ac = dynamic_cast<C *>(a);
27 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64 }* @_ZTI1C to i8*), i64 -2)
28   volatile D *ad = dynamic_cast<D *>(a);
29 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i8* }* @_ZTI1D to i8*), i64 0)
30   volatile E *ae = dynamic_cast<E *>(a);
31 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1E to i8*), i64 0)
32   volatile F *af = dynamic_cast<F *>(a);
33 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64 }* @_ZTI1F to i8*), i64 -1)
34   volatile G *ag = dynamic_cast<G *>(a);
35 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64 }* @_ZTI1G to i8*), i64 -2)
36   volatile H *ah = dynamic_cast<H *>(a);
37 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i8* }* @_ZTI1H to i8*), i64 0)
38   volatile I *ai = dynamic_cast<I *>(a);
39 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i8* }* @_ZTI1I to i8*), i64 -1)
40   volatile J *aj = dynamic_cast<J *>(a);
41 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i8* }* @_ZTI1J to i8*), i64 0)
42   volatile K *ak = dynamic_cast<K *>(a);
43 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1K to i8*), i64 -2)
44   volatile X *ax = dynamic_cast<X *>(a);
45 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64, i8*, i64 }* @_ZTI1X to i8*), i64 -1)
46 
47   volatile E *be = dynamic_cast<E *>(b);
48 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1B to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1E to i8*), i64 8)
49   volatile G *bg = dynamic_cast<G *>(b);
50 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1B to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64 }* @_ZTI1G to i8*), i64 -2)
51   volatile J *bj = dynamic_cast<J *>(b);
52 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1B to i8*), i8* bitcast ({ i8*, i8*, i8* }* @_ZTI1J to i8*), i64 8)
53   volatile K *bk = dynamic_cast<K *>(b);
54 // CHECK: i8* bitcast ({ i8*, i8* }* @_ZTI1B to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1K to i8*), i64 16)
55 }
56