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