diff options
author | Anders Carlsson <andersca@mac.com> | 2009-12-30 01:00:12 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-12-30 01:00:12 +0000 |
commit | f64531a17037faa9e0119e90961d2db77d06865d (patch) | |
tree | 27a4c6f8005b8782f9726f42b02e98c64bb7b452 /test/CodeGenCXX/rtti-layout.cpp | |
parent | 5126fd0dd92c4ec211c837ee78d5ce59c68dcbd5 (diff) |
More RTTI cleanup, test that RTTI classes have the correct vtables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92284 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/rtti-layout.cpp')
-rw-r--r-- | test/CodeGenCXX/rtti-layout.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/test/CodeGenCXX/rtti-layout.cpp b/test/CodeGenCXX/rtti-layout.cpp index c8326bbd89..e3b5456f4d 100644 --- a/test/CodeGenCXX/rtti-layout.cpp +++ b/test/CodeGenCXX/rtti-layout.cpp @@ -1,6 +1,20 @@ // RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s #include <typeinfo> +// vtables. +extern "C" { + const void *_ZTVN10__cxxabiv123__fundamental_type_infoE; + const void *_ZTVN10__cxxabiv117__class_type_infoE; + const void *_ZTVN10__cxxabiv120__si_class_type_infoE; + const void *_ZTVN10__cxxabiv119__pointer_type_infoE; + const void *_ZTVN10__cxxabiv129__pointer_to_member_type_infoE; +}; +#define fundamental_type_info_vtable _ZTVN10__cxxabiv123__fundamental_type_infoE +#define class_type_info_vtable _ZTVN10__cxxabiv117__class_type_infoE +#define si_class_type_info_vtable _ZTVN10__cxxabiv120__si_class_type_infoE +#define pointer_type_info_vtable _ZTVN10__cxxabiv119__pointer_type_infoE +#define pointer_to_member_type_info_vtable _ZTVN10__cxxabiv129__pointer_to_member_type_infoE + class __pbase_type_info : public std::type_info { public: unsigned int __flags; @@ -22,16 +36,23 @@ struct Incomplete; struct A { }; -#define CHECK(x) if (!(x)) return __LINE__; +#define CHECK(x) if (!(x)) return __LINE__ +#define CHECK_VTABLE(type, vtable) if (&vtable##_type_info_vtable + 2 != (((void **)&(typeid(type)))[0])) return __LINE__ // CHECK: define i32 @_Z1fv() int f() { + // Vectors should be treated as fundamental types. + typedef short __v4hi __attribute__ ((__vector_size__ (8))); + CHECK_VTABLE(__v4hi, fundamental); + // Pointers to incomplete classes. + CHECK_VTABLE(Incomplete *, pointer); CHECK(to<__pbase_type_info>(typeid(Incomplete *)).__flags == __pbase_type_info::__incomplete_mask); CHECK(to<__pbase_type_info>(typeid(Incomplete **)).__flags == __pbase_type_info::__incomplete_mask); CHECK(to<__pbase_type_info>(typeid(Incomplete ***)).__flags == __pbase_type_info::__incomplete_mask); // Member pointers. + CHECK_VTABLE(int Incomplete::*, pointer_to_member); CHECK(to<__pbase_type_info>(typeid(int Incomplete::*)).__flags == __pbase_type_info::__incomplete_class_mask); CHECK(to<__pbase_type_info>(typeid(Incomplete Incomplete::*)).__flags == (__pbase_type_info::__incomplete_class_mask | __pbase_type_info::__incomplete_mask)); CHECK(to<__pbase_type_info>(typeid(Incomplete A::*)).__flags == (__pbase_type_info::__incomplete_mask)); |