Mike Stump | de05057 | 2009-12-02 18:57:08 +0000 | [diff] [blame] | 1 | //===--- CGCXXRTTI.cpp - Emit LLVM Code for C++ RTTI descriptors ----------===// |
Anders Carlsson | 656e4c1 | 2009-10-10 20:49:04 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This contains code dealing with C++ code generation of RTTI descriptors. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Mike Stump | ae9b2be | 2009-11-17 23:45:57 +0000 | [diff] [blame] | 14 | #include "clang/AST/Type.h" |
Mike Stump | cbcd4e5 | 2009-11-14 23:32:21 +0000 | [diff] [blame] | 15 | #include "clang/AST/RecordLayout.h" |
Mike Stump | 61c3801 | 2009-11-17 21:44:24 +0000 | [diff] [blame] | 16 | #include "CodeGenModule.h" |
Anders Carlsson | 656e4c1 | 2009-10-10 20:49:04 +0000 | [diff] [blame] | 17 | using namespace clang; |
| 18 | using namespace CodeGen; |
| 19 | |
Mike Stump | 92f2fe2 | 2009-12-02 19:07:44 +0000 | [diff] [blame] | 20 | namespace { |
Mike Stump | de05057 | 2009-12-02 18:57:08 +0000 | [diff] [blame] | 21 | class RTTIBuilder { |
Mike Stump | 2b1bf31 | 2009-11-14 14:25:18 +0000 | [diff] [blame] | 22 | CodeGenModule &CGM; // Per-module state. |
| 23 | llvm::LLVMContext &VMContext; |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 24 | |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 25 | const llvm::Type *Int8PtrTy; |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 26 | |
| 27 | /// Fields - The fields of the RTTI descriptor currently being built. |
| 28 | llvm::SmallVector<llvm::Constant *, 16> Fields; |
Anders Carlsson | d6baec8 | 2009-12-11 01:27:37 +0000 | [diff] [blame] | 29 | |
Anders Carlsson | 1d7088d | 2009-12-17 07:09:17 +0000 | [diff] [blame] | 30 | /// GetAddrOfExternalRTTIDescriptor - Returns the constant for the RTTI |
| 31 | /// descriptor of the given type. |
| 32 | llvm::Constant *GetAddrOfExternalRTTIDescriptor(QualType Ty); |
| 33 | |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 34 | /// BuildVTablePointer - Build the vtable pointer for the given type. |
| 35 | void BuildVTablePointer(const Type *Ty); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 36 | |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 37 | /// BuildSIClassTypeInfo - Build an abi::__si_class_type_info, used for single |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 38 | /// inheritance, according to the Itanium C++ ABI, 2.9.5p6b. |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 39 | void BuildSIClassTypeInfo(const CXXRecordDecl *RD); |
| 40 | |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 41 | /// BuildVMIClassTypeInfo - Build an abi::__vmi_class_type_info, used for |
| 42 | /// classes with bases that do not satisfy the abi::__si_class_type_info |
| 43 | /// constraints, according ti the Itanium C++ ABI, 2.9.5p5c. |
| 44 | void BuildVMIClassTypeInfo(const CXXRecordDecl *RD); |
| 45 | |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 46 | /// BuildPointerTypeInfo - Build an abi::__pointer_type_info struct, used |
| 47 | /// for pointer types. |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 48 | void BuildPointerTypeInfo(QualType PointeeTy); |
| 49 | |
| 50 | /// BuildObjCObjectTypeInfo - Build the appropriate kind of |
| 51 | /// type_info for an object type. |
| 52 | void BuildObjCObjectTypeInfo(const ObjCObjectType *Ty); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 53 | |
| 54 | /// BuildPointerToMemberTypeInfo - Build an abi::__pointer_to_member_type_info |
| 55 | /// struct, used for member pointer types. |
| 56 | void BuildPointerToMemberTypeInfo(const MemberPointerType *Ty); |
| 57 | |
Mike Stump | 2b1bf31 | 2009-11-14 14:25:18 +0000 | [diff] [blame] | 58 | public: |
Mike Stump | de05057 | 2009-12-02 18:57:08 +0000 | [diff] [blame] | 59 | RTTIBuilder(CodeGenModule &cgm) |
Mike Stump | 2b1bf31 | 2009-11-14 14:25:18 +0000 | [diff] [blame] | 60 | : CGM(cgm), VMContext(cgm.getModule().getContext()), |
| 61 | Int8PtrTy(llvm::Type::getInt8PtrTy(VMContext)) { } |
| 62 | |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 63 | llvm::Constant *BuildName(QualType Ty, bool Hidden, |
| 64 | llvm::GlobalVariable::LinkageTypes Linkage) { |
Mike Stump | 2b1bf31 | 2009-11-14 14:25:18 +0000 | [diff] [blame] | 65 | llvm::SmallString<256> OutName; |
Mike Stump | de05057 | 2009-12-02 18:57:08 +0000 | [diff] [blame] | 66 | CGM.getMangleContext().mangleCXXRTTIName(Ty, OutName); |
Daniel Dunbar | 94fd26d | 2009-11-21 09:06:22 +0000 | [diff] [blame] | 67 | llvm::StringRef Name = OutName.str(); |
Mike Stump | cbcd4e5 | 2009-11-14 23:32:21 +0000 | [diff] [blame] | 68 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 69 | llvm::GlobalVariable *OGV = CGM.getModule().getNamedGlobal(Name); |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 70 | if (OGV && !OGV->isDeclaration()) |
| 71 | return llvm::ConstantExpr::getBitCast(OGV, Int8PtrTy); |
Mike Stump | 5858894 | 2009-11-19 01:08:19 +0000 | [diff] [blame] | 72 | |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 73 | llvm::Constant *C = llvm::ConstantArray::get(VMContext, Name.substr(4)); |
Mike Stump | 2b1bf31 | 2009-11-14 14:25:18 +0000 | [diff] [blame] | 74 | |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 75 | llvm::GlobalVariable *GV = |
| 76 | new llvm::GlobalVariable(CGM.getModule(), C->getType(), true, Linkage, |
| 77 | C, Name); |
Mike Stump | 5858894 | 2009-11-19 01:08:19 +0000 | [diff] [blame] | 78 | if (OGV) { |
| 79 | GV->takeName(OGV); |
| 80 | llvm::Constant *NewPtr = llvm::ConstantExpr::getBitCast(GV, |
| 81 | OGV->getType()); |
| 82 | OGV->replaceAllUsesWith(NewPtr); |
| 83 | OGV->eraseFromParent(); |
| 84 | } |
Mike Stump | 582b037 | 2009-11-18 03:46:51 +0000 | [diff] [blame] | 85 | if (Hidden) |
| 86 | GV->setVisibility(llvm::GlobalVariable::HiddenVisibility); |
| 87 | return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy); |
Daniel Dunbar | 7177dee | 2009-12-19 17:50:07 +0000 | [diff] [blame] | 88 | } |
Mike Stump | c7a05bd | 2009-11-14 15:55:18 +0000 | [diff] [blame] | 89 | |
Mike Stump | 4e6f8ee | 2009-12-24 02:33:48 +0000 | [diff] [blame] | 90 | // FIXME: unify with DecideExtern |
Mike Stump | 5858894 | 2009-11-19 01:08:19 +0000 | [diff] [blame] | 91 | bool DecideHidden(QualType Ty) { |
| 92 | // For this type, see if all components are never hidden. |
| 93 | if (const MemberPointerType *MPT = Ty->getAs<MemberPointerType>()) |
| 94 | return (DecideHidden(MPT->getPointeeType()) |
| 95 | && DecideHidden(QualType(MPT->getClass(), 0))); |
| 96 | if (const PointerType *PT = Ty->getAs<PointerType>()) |
| 97 | return DecideHidden(PT->getPointeeType()); |
Mike Stump | 4e6f8ee | 2009-12-24 02:33:48 +0000 | [diff] [blame] | 98 | if (const FunctionType *FT = Ty->getAs<FunctionType>()) { |
| 99 | if (DecideHidden(FT->getResultType()) == false) |
| 100 | return false; |
| 101 | if (const FunctionProtoType *FPT = Ty->getAs<FunctionProtoType>()) { |
| 102 | for (unsigned i = 0; i <FPT->getNumArgs(); ++i) |
| 103 | if (DecideHidden(FPT->getArgType(i)) == false) |
| 104 | return false; |
| 105 | for (unsigned i = 0; i <FPT->getNumExceptions(); ++i) |
| 106 | if (DecideHidden(FPT->getExceptionType(i)) == false) |
| 107 | return false; |
| 108 | return true; |
| 109 | } |
| 110 | } |
Mike Stump | 5858894 | 2009-11-19 01:08:19 +0000 | [diff] [blame] | 111 | if (const RecordType *RT = Ty->getAs<RecordType>()) |
| 112 | if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl())) |
| 113 | return CGM.getDeclVisibilityMode(RD) == LangOptions::Hidden; |
| 114 | return false; |
| 115 | } |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 116 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 117 | // Pointer type info flags. |
| 118 | enum { |
| 119 | /// PTI_Const - Type has const qualifier. |
| 120 | PTI_Const = 0x1, |
| 121 | |
| 122 | /// PTI_Volatile - Type has volatile qualifier. |
| 123 | PTI_Volatile = 0x2, |
| 124 | |
| 125 | /// PTI_Restrict - Type has restrict qualifier. |
| 126 | PTI_Restrict = 0x4, |
| 127 | |
| 128 | /// PTI_Incomplete - Type is incomplete. |
| 129 | PTI_Incomplete = 0x8, |
| 130 | |
| 131 | /// PTI_ContainingClassIncomplete - Containing class is incomplete. |
| 132 | /// (in pointer to member). |
| 133 | PTI_ContainingClassIncomplete = 0x10 |
| 134 | }; |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 135 | |
| 136 | // VMI type info flags. |
| 137 | enum { |
| 138 | /// VMI_NonDiamondRepeat - Class has non-diamond repeated inheritance. |
| 139 | VMI_NonDiamondRepeat = 0x1, |
| 140 | |
| 141 | /// VMI_DiamondShaped - Class is diamond shaped. |
| 142 | VMI_DiamondShaped = 0x2 |
| 143 | }; |
| 144 | |
| 145 | // Base class type info flags. |
| 146 | enum { |
| 147 | /// BCTI_Virtual - Base class is virtual. |
| 148 | BCTI_Virtual = 0x1, |
| 149 | |
| 150 | /// BCTI_Public - Base class is public. |
| 151 | BCTI_Public = 0x2 |
| 152 | }; |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 153 | |
| 154 | /// BuildTypeInfo - Build the RTTI type info struct for the given type. |
John McCall | 9dffe6f | 2010-04-30 01:15:21 +0000 | [diff] [blame] | 155 | /// |
| 156 | /// \param Force - true to force the creation of this RTTI value |
| 157 | /// \param ForEH - true if this is for exception handling |
Rafael Espindola | d1a5c31 | 2010-03-27 02:52:14 +0000 | [diff] [blame] | 158 | llvm::Constant *BuildTypeInfo(QualType Ty, bool Force = false); |
Mike Stump | 2b1bf31 | 2009-11-14 14:25:18 +0000 | [diff] [blame] | 159 | }; |
Mike Stump | 92f2fe2 | 2009-12-02 19:07:44 +0000 | [diff] [blame] | 160 | } |
Mike Stump | 2b1bf31 | 2009-11-14 14:25:18 +0000 | [diff] [blame] | 161 | |
Anders Carlsson | 1d7088d | 2009-12-17 07:09:17 +0000 | [diff] [blame] | 162 | llvm::Constant *RTTIBuilder::GetAddrOfExternalRTTIDescriptor(QualType Ty) { |
| 163 | // Mangle the RTTI name. |
| 164 | llvm::SmallString<256> OutName; |
| 165 | CGM.getMangleContext().mangleCXXRTTI(Ty, OutName); |
| 166 | llvm::StringRef Name = OutName.str(); |
| 167 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 168 | // Look for an existing global. |
| 169 | llvm::GlobalVariable *GV = CGM.getModule().getNamedGlobal(Name); |
Anders Carlsson | 1d7088d | 2009-12-17 07:09:17 +0000 | [diff] [blame] | 170 | |
| 171 | if (!GV) { |
| 172 | // Create a new global variable. |
| 173 | GV = new llvm::GlobalVariable(CGM.getModule(), Int8PtrTy, /*Constant=*/true, |
| 174 | llvm::GlobalValue::ExternalLinkage, 0, Name); |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 175 | } |
| 176 | |
Anders Carlsson | 1d7088d | 2009-12-17 07:09:17 +0000 | [diff] [blame] | 177 | return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy); |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 180 | /// TypeInfoIsInStandardLibrary - Given a builtin type, returns whether the type |
| 181 | /// info for that type is defined in the standard library. |
| 182 | static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) { |
| 183 | // Itanium C++ ABI 2.9.2: |
| 184 | // Basic type information (e.g. for "int", "bool", etc.) will be kept in |
| 185 | // the run-time support library. Specifically, the run-time support |
| 186 | // library should contain type_info objects for the types X, X* and |
| 187 | // X const*, for every X in: void, bool, wchar_t, char, unsigned char, |
| 188 | // signed char, short, unsigned short, int, unsigned int, long, |
| 189 | // unsigned long, long long, unsigned long long, float, double, long double, |
| 190 | // char16_t, char32_t, and the IEEE 754r decimal and half-precision |
| 191 | // floating point types. |
| 192 | switch (Ty->getKind()) { |
| 193 | case BuiltinType::Void: |
| 194 | case BuiltinType::Bool: |
| 195 | case BuiltinType::WChar: |
| 196 | case BuiltinType::Char_U: |
| 197 | case BuiltinType::Char_S: |
| 198 | case BuiltinType::UChar: |
| 199 | case BuiltinType::SChar: |
| 200 | case BuiltinType::Short: |
| 201 | case BuiltinType::UShort: |
| 202 | case BuiltinType::Int: |
| 203 | case BuiltinType::UInt: |
| 204 | case BuiltinType::Long: |
| 205 | case BuiltinType::ULong: |
| 206 | case BuiltinType::LongLong: |
| 207 | case BuiltinType::ULongLong: |
| 208 | case BuiltinType::Float: |
| 209 | case BuiltinType::Double: |
| 210 | case BuiltinType::LongDouble: |
| 211 | case BuiltinType::Char16: |
| 212 | case BuiltinType::Char32: |
| 213 | case BuiltinType::Int128: |
| 214 | case BuiltinType::UInt128: |
| 215 | return true; |
| 216 | |
| 217 | case BuiltinType::Overload: |
| 218 | case BuiltinType::Dependent: |
| 219 | case BuiltinType::UndeducedAuto: |
| 220 | assert(false && "Should not see this type here!"); |
| 221 | |
| 222 | case BuiltinType::NullPtr: |
| 223 | assert(false && "FIXME: nullptr_t is not handled!"); |
| 224 | |
| 225 | case BuiltinType::ObjCId: |
| 226 | case BuiltinType::ObjCClass: |
| 227 | case BuiltinType::ObjCSel: |
| 228 | assert(false && "FIXME: Objective-C types are unsupported!"); |
| 229 | } |
| 230 | |
| 231 | // Silent gcc. |
| 232 | return false; |
| 233 | } |
| 234 | |
| 235 | static bool TypeInfoIsInStandardLibrary(const PointerType *PointerTy) { |
| 236 | QualType PointeeTy = PointerTy->getPointeeType(); |
| 237 | const BuiltinType *BuiltinTy = dyn_cast<BuiltinType>(PointeeTy); |
| 238 | if (!BuiltinTy) |
| 239 | return false; |
| 240 | |
| 241 | // Check the qualifiers. |
| 242 | Qualifiers Quals = PointeeTy.getQualifiers(); |
| 243 | Quals.removeConst(); |
| 244 | |
| 245 | if (!Quals.empty()) |
| 246 | return false; |
| 247 | |
| 248 | return TypeInfoIsInStandardLibrary(BuiltinTy); |
| 249 | } |
| 250 | |
John McCall | cbfe502 | 2010-08-04 08:34:44 +0000 | [diff] [blame] | 251 | /// IsStandardLibraryRTTIDescriptor - Returns whether the type |
| 252 | /// information for the given type exists in the standard library. |
| 253 | static bool IsStandardLibraryRTTIDescriptor(QualType Ty) { |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 254 | // Type info for builtin types is defined in the standard library. |
| 255 | if (const BuiltinType *BuiltinTy = dyn_cast<BuiltinType>(Ty)) |
| 256 | return TypeInfoIsInStandardLibrary(BuiltinTy); |
| 257 | |
| 258 | // Type info for some pointer types to builtin types is defined in the |
| 259 | // standard library. |
| 260 | if (const PointerType *PointerTy = dyn_cast<PointerType>(Ty)) |
| 261 | return TypeInfoIsInStandardLibrary(PointerTy); |
| 262 | |
John McCall | cbfe502 | 2010-08-04 08:34:44 +0000 | [diff] [blame] | 263 | return false; |
| 264 | } |
| 265 | |
| 266 | /// ShouldUseExternalRTTIDescriptor - Returns whether the type information for |
| 267 | /// the given type exists somewhere else, and that we should not emit the type |
| 268 | /// information in this translation unit. Assumes that it is not a |
| 269 | /// standard-library type. |
| 270 | static bool ShouldUseExternalRTTIDescriptor(ASTContext &Context, |
| 271 | QualType Ty) { |
John McCall | 9dffe6f | 2010-04-30 01:15:21 +0000 | [diff] [blame] | 272 | // If RTTI is disabled, don't consider key functions. |
| 273 | if (!Context.getLangOptions().RTTI) return false; |
| 274 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 275 | if (const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) { |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 276 | const CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl()); |
John McCall | 86ff308 | 2010-02-04 22:26:26 +0000 | [diff] [blame] | 277 | if (!RD->hasDefinition()) |
| 278 | return false; |
| 279 | |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 280 | if (!RD->isDynamicClass()) |
| 281 | return false; |
| 282 | |
| 283 | // Get the key function. |
| 284 | const CXXMethodDecl *KeyFunction = RD->getASTContext().getKeyFunction(RD); |
Argyrios Kyrtzidis | 4aedb1c | 2010-07-07 12:24:18 +0000 | [diff] [blame] | 285 | if (KeyFunction && !KeyFunction->hasBody()) { |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 286 | // The class has a key function, but it is not defined in this translation |
| 287 | // unit, so we should use the external descriptor for it. |
| 288 | return true; |
| 289 | } |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | /// IsIncompleteClassType - Returns whether the given record type is incomplete. |
| 296 | static bool IsIncompleteClassType(const RecordType *RecordTy) { |
| 297 | return !RecordTy->getDecl()->isDefinition(); |
| 298 | } |
| 299 | |
Anders Carlsson | 17fa6f9 | 2009-12-20 23:37:55 +0000 | [diff] [blame] | 300 | /// ContainsIncompleteClassType - Returns whether the given type contains an |
| 301 | /// incomplete class type. This is true if |
| 302 | /// |
| 303 | /// * The given type is an incomplete class type. |
| 304 | /// * The given type is a pointer type whose pointee type contains an |
| 305 | /// incomplete class type. |
| 306 | /// * The given type is a member pointer type whose class is an incomplete |
| 307 | /// class type. |
| 308 | /// * The given type is a member pointer type whoise pointee type contains an |
| 309 | /// incomplete class type. |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 310 | /// is an indirect or direct pointer to an incomplete class type. |
Anders Carlsson | 17fa6f9 | 2009-12-20 23:37:55 +0000 | [diff] [blame] | 311 | static bool ContainsIncompleteClassType(QualType Ty) { |
| 312 | if (const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) { |
| 313 | if (IsIncompleteClassType(RecordTy)) |
| 314 | return true; |
| 315 | } |
| 316 | |
| 317 | if (const PointerType *PointerTy = dyn_cast<PointerType>(Ty)) |
| 318 | return ContainsIncompleteClassType(PointerTy->getPointeeType()); |
| 319 | |
| 320 | if (const MemberPointerType *MemberPointerTy = |
| 321 | dyn_cast<MemberPointerType>(Ty)) { |
| 322 | // Check if the class type is incomplete. |
| 323 | const RecordType *ClassType = cast<RecordType>(MemberPointerTy->getClass()); |
| 324 | if (IsIncompleteClassType(ClassType)) |
| 325 | return true; |
| 326 | |
| 327 | return ContainsIncompleteClassType(MemberPointerTy->getPointeeType()); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | return false; |
| 331 | } |
| 332 | |
| 333 | /// getTypeInfoLinkage - Return the linkage that the type info and type info |
| 334 | /// name constants should have for the given type. |
| 335 | static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(QualType Ty) { |
Anders Carlsson | 17fa6f9 | 2009-12-20 23:37:55 +0000 | [diff] [blame] | 336 | // Itanium C++ ABI 2.9.5p7: |
| 337 | // In addition, it and all of the intermediate abi::__pointer_type_info |
| 338 | // structs in the chain down to the abi::__class_type_info for the |
| 339 | // incomplete class type must be prevented from resolving to the |
| 340 | // corresponding type_info structs for the complete class type, possibly |
| 341 | // by making them local static objects. Finally, a dummy class RTTI is |
| 342 | // generated for the incomplete type that will not resolve to the final |
| 343 | // complete class RTTI (because the latter need not exist), possibly by |
| 344 | // making it a local static object. |
| 345 | if (ContainsIncompleteClassType(Ty)) |
| 346 | return llvm::GlobalValue::InternalLinkage; |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 347 | |
Douglas Gregor | 031b371 | 2010-03-31 00:15:35 +0000 | [diff] [blame] | 348 | switch (Ty->getLinkage()) { |
| 349 | case NoLinkage: |
| 350 | case InternalLinkage: |
| 351 | case UniqueExternalLinkage: |
| 352 | return llvm::GlobalValue::InternalLinkage; |
Anders Carlsson | 978ef68 | 2009-12-29 21:58:32 +0000 | [diff] [blame] | 353 | |
Douglas Gregor | 031b371 | 2010-03-31 00:15:35 +0000 | [diff] [blame] | 354 | case ExternalLinkage: |
| 355 | if (const RecordType *Record = dyn_cast<RecordType>(Ty)) { |
| 356 | const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl()); |
| 357 | if (RD->isDynamicClass()) |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 358 | return CodeGenModule::getVTableLinkage(RD); |
Mike Stump | c8f76f5 | 2009-12-24 01:10:27 +0000 | [diff] [blame] | 359 | } |
Douglas Gregor | 031b371 | 2010-03-31 00:15:35 +0000 | [diff] [blame] | 360 | |
Mike Stump | c8f76f5 | 2009-12-24 01:10:27 +0000 | [diff] [blame] | 361 | return llvm::GlobalValue::WeakODRLinkage; |
| 362 | } |
Anders Carlsson | 978ef68 | 2009-12-29 21:58:32 +0000 | [diff] [blame] | 363 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 364 | return llvm::GlobalValue::WeakODRLinkage; |
| 365 | } |
| 366 | |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 367 | // CanUseSingleInheritance - Return whether the given record decl has a "single, |
| 368 | // public, non-virtual base at offset zero (i.e. the derived class is dynamic |
| 369 | // iff the base is)", according to Itanium C++ ABI, 2.95p6b. |
| 370 | static bool CanUseSingleInheritance(const CXXRecordDecl *RD) { |
| 371 | // Check the number of bases. |
| 372 | if (RD->getNumBases() != 1) |
| 373 | return false; |
| 374 | |
| 375 | // Get the base. |
| 376 | CXXRecordDecl::base_class_const_iterator Base = RD->bases_begin(); |
| 377 | |
| 378 | // Check that the base is not virtual. |
| 379 | if (Base->isVirtual()) |
| 380 | return false; |
| 381 | |
| 382 | // Check that the base is public. |
| 383 | if (Base->getAccessSpecifier() != AS_public) |
| 384 | return false; |
| 385 | |
| 386 | // Check that the class is dynamic iff the base is. |
| 387 | const CXXRecordDecl *BaseDecl = |
| 388 | cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); |
| 389 | if (!BaseDecl->isEmpty() && |
| 390 | BaseDecl->isDynamicClass() != RD->isDynamicClass()) |
| 391 | return false; |
| 392 | |
| 393 | return true; |
| 394 | } |
| 395 | |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 396 | void RTTIBuilder::BuildVTablePointer(const Type *Ty) { |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 397 | // abi::__class_type_info. |
| 398 | static const char * const ClassTypeInfo = |
| 399 | "_ZTVN10__cxxabiv117__class_type_infoE"; |
| 400 | // abi::__si_class_type_info. |
| 401 | static const char * const SIClassTypeInfo = |
| 402 | "_ZTVN10__cxxabiv120__si_class_type_infoE"; |
| 403 | // abi::__vmi_class_type_info. |
| 404 | static const char * const VMIClassTypeInfo = |
| 405 | "_ZTVN10__cxxabiv121__vmi_class_type_infoE"; |
| 406 | |
Eli Friedman | 1cf26f5 | 2010-08-11 20:41:51 +0000 | [diff] [blame] | 407 | const char *VTableName = 0; |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 408 | |
| 409 | switch (Ty->getTypeClass()) { |
Eli Friedman | 1cf26f5 | 2010-08-11 20:41:51 +0000 | [diff] [blame] | 410 | #define TYPE(Class, Base) |
| 411 | #define ABSTRACT_TYPE(Class, Base) |
| 412 | #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class: |
| 413 | #define NON_CANONICAL_TYPE(Class, Base) case Type::Class: |
| 414 | #define DEPENDENT_TYPE(Class, Base) case Type::Class: |
| 415 | #include "clang/AST/TypeNodes.def" |
| 416 | assert(false && "Non-canonical and dependent types shouldn't get here"); |
| 417 | |
| 418 | case Type::LValueReference: |
| 419 | case Type::RValueReference: |
| 420 | assert(false && "References shouldn't get here"); |
Anders Carlsson | 978ef68 | 2009-12-29 21:58:32 +0000 | [diff] [blame] | 421 | |
Rafael Espindola | d1a5c31 | 2010-03-27 02:52:14 +0000 | [diff] [blame] | 422 | case Type::Builtin: |
Eli Friedman | 1cf26f5 | 2010-08-11 20:41:51 +0000 | [diff] [blame] | 423 | // GCC treats vector and complex types as fundamental types. |
Anders Carlsson | c8cfd63 | 2009-12-29 22:30:11 +0000 | [diff] [blame] | 424 | case Type::Vector: |
| 425 | case Type::ExtVector: |
Eli Friedman | 1cf26f5 | 2010-08-11 20:41:51 +0000 | [diff] [blame] | 426 | case Type::Complex: |
| 427 | // FIXME: GCC treats block pointers as fundamental types?! |
| 428 | case Type::BlockPointer: |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 429 | // abi::__fundamental_type_info. |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 430 | VTableName = "_ZTVN10__cxxabiv123__fundamental_type_infoE"; |
Anders Carlsson | c8cfd63 | 2009-12-29 22:30:11 +0000 | [diff] [blame] | 431 | break; |
| 432 | |
Anders Carlsson | 978ef68 | 2009-12-29 21:58:32 +0000 | [diff] [blame] | 433 | case Type::ConstantArray: |
| 434 | case Type::IncompleteArray: |
Eli Friedman | 1cf26f5 | 2010-08-11 20:41:51 +0000 | [diff] [blame] | 435 | case Type::VariableArray: |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 436 | // abi::__array_type_info. |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 437 | VTableName = "_ZTVN10__cxxabiv117__array_type_infoE"; |
Anders Carlsson | 978ef68 | 2009-12-29 21:58:32 +0000 | [diff] [blame] | 438 | break; |
| 439 | |
| 440 | case Type::FunctionNoProto: |
| 441 | case Type::FunctionProto: |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 442 | // abi::__function_type_info. |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 443 | VTableName = "_ZTVN10__cxxabiv120__function_type_infoE"; |
Anders Carlsson | 978ef68 | 2009-12-29 21:58:32 +0000 | [diff] [blame] | 444 | break; |
| 445 | |
Anders Carlsson | 9c7b6bb | 2009-12-29 22:13:01 +0000 | [diff] [blame] | 446 | case Type::Enum: |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 447 | // abi::__enum_type_info. |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 448 | VTableName = "_ZTVN10__cxxabiv116__enum_type_infoE"; |
Anders Carlsson | 9c7b6bb | 2009-12-29 22:13:01 +0000 | [diff] [blame] | 449 | break; |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 450 | |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 451 | case Type::Record: { |
| 452 | const CXXRecordDecl *RD = |
| 453 | cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl()); |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 454 | |
John McCall | 86ff308 | 2010-02-04 22:26:26 +0000 | [diff] [blame] | 455 | if (!RD->hasDefinition() || !RD->getNumBases()) { |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 456 | VTableName = ClassTypeInfo; |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 457 | } else if (CanUseSingleInheritance(RD)) { |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 458 | VTableName = SIClassTypeInfo; |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 459 | } else { |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 460 | VTableName = VMIClassTypeInfo; |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 461 | } |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 462 | |
| 463 | break; |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 464 | } |
| 465 | |
Eli Friedman | 1cf26f5 | 2010-08-11 20:41:51 +0000 | [diff] [blame] | 466 | case Type::ObjCObject: |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 467 | // Ignore protocol qualifiers. |
| 468 | Ty = cast<ObjCObjectType>(Ty)->getBaseType().getTypePtr(); |
| 469 | |
| 470 | // Handle id and Class. |
| 471 | if (isa<BuiltinType>(Ty)) { |
| 472 | VTableName = ClassTypeInfo; |
| 473 | break; |
| 474 | } |
| 475 | |
| 476 | assert(isa<ObjCInterfaceType>(Ty)); |
| 477 | // Fall through. |
| 478 | |
Eli Friedman | 1cf26f5 | 2010-08-11 20:41:51 +0000 | [diff] [blame] | 479 | case Type::ObjCInterface: |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 480 | if (cast<ObjCInterfaceType>(Ty)->getDecl()->getSuperClass()) { |
| 481 | VTableName = SIClassTypeInfo; |
| 482 | } else { |
| 483 | VTableName = ClassTypeInfo; |
| 484 | } |
Eli Friedman | 1cf26f5 | 2010-08-11 20:41:51 +0000 | [diff] [blame] | 485 | break; |
| 486 | |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 487 | case Type::ObjCObjectPointer: |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 488 | case Type::Pointer: |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 489 | // abi::__pointer_type_info. |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 490 | VTableName = "_ZTVN10__cxxabiv119__pointer_type_infoE"; |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 491 | break; |
Anders Carlsson | 978ef68 | 2009-12-29 21:58:32 +0000 | [diff] [blame] | 492 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 493 | case Type::MemberPointer: |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 494 | // abi::__pointer_to_member_type_info. |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 495 | VTableName = "_ZTVN10__cxxabiv129__pointer_to_member_type_infoE"; |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 496 | break; |
| 497 | } |
| 498 | |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 499 | llvm::Constant *VTable = |
| 500 | CGM.getModule().getOrInsertGlobal(VTableName, Int8PtrTy); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 501 | |
| 502 | const llvm::Type *PtrDiffTy = |
| 503 | CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType()); |
| 504 | |
| 505 | // The vtable address point is 2. |
| 506 | llvm::Constant *Two = llvm::ConstantInt::get(PtrDiffTy, 2); |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 507 | VTable = llvm::ConstantExpr::getInBoundsGetElementPtr(VTable, &Two, 1); |
| 508 | VTable = llvm::ConstantExpr::getBitCast(VTable, Int8PtrTy); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 509 | |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 510 | Fields.push_back(VTable); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 511 | } |
| 512 | |
John McCall | cbfe502 | 2010-08-04 08:34:44 +0000 | [diff] [blame] | 513 | llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) { |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 514 | // We want to operate on the canonical type. |
| 515 | Ty = CGM.getContext().getCanonicalType(Ty); |
| 516 | |
| 517 | // Check if we've already emitted an RTTI descriptor for this type. |
| 518 | llvm::SmallString<256> OutName; |
| 519 | CGM.getMangleContext().mangleCXXRTTI(Ty, OutName); |
| 520 | llvm::StringRef Name = OutName.str(); |
| 521 | |
| 522 | llvm::GlobalVariable *OldGV = CGM.getModule().getNamedGlobal(Name); |
| 523 | if (OldGV && !OldGV->isDeclaration()) |
| 524 | return llvm::ConstantExpr::getBitCast(OldGV, Int8PtrTy); |
John McCall | cbfe502 | 2010-08-04 08:34:44 +0000 | [diff] [blame] | 525 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 526 | // Check if there is already an external RTTI descriptor for this type. |
John McCall | cbfe502 | 2010-08-04 08:34:44 +0000 | [diff] [blame] | 527 | bool IsStdLib = IsStandardLibraryRTTIDescriptor(Ty); |
| 528 | if (!Force && |
| 529 | (IsStdLib || ShouldUseExternalRTTIDescriptor(CGM.getContext(), Ty))) |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 530 | return GetAddrOfExternalRTTIDescriptor(Ty); |
| 531 | |
John McCall | cbfe502 | 2010-08-04 08:34:44 +0000 | [diff] [blame] | 532 | // Emit the standard library with external linkage. |
| 533 | llvm::GlobalVariable::LinkageTypes Linkage; |
| 534 | if (IsStdLib) |
| 535 | Linkage = llvm::GlobalValue::ExternalLinkage; |
| 536 | else |
| 537 | Linkage = getTypeInfoLinkage(Ty); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 538 | |
| 539 | // Add the vtable pointer. |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 540 | BuildVTablePointer(cast<Type>(Ty)); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 541 | |
| 542 | // And the name. |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 543 | Fields.push_back(BuildName(Ty, DecideHidden(Ty), Linkage)); |
John McCall | cbfe502 | 2010-08-04 08:34:44 +0000 | [diff] [blame] | 544 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 545 | switch (Ty->getTypeClass()) { |
| 546 | default: assert(false && "Unhandled type class!"); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 547 | |
Anders Carlsson | c8cfd63 | 2009-12-29 22:30:11 +0000 | [diff] [blame] | 548 | // GCC treats vector types as fundamental types. |
Rafael Espindola | d1a5c31 | 2010-03-27 02:52:14 +0000 | [diff] [blame] | 549 | case Type::Builtin: |
Anders Carlsson | c8cfd63 | 2009-12-29 22:30:11 +0000 | [diff] [blame] | 550 | case Type::Vector: |
| 551 | case Type::ExtVector: |
| 552 | // Itanium C++ ABI 2.9.5p4: |
| 553 | // abi::__fundamental_type_info adds no data members to std::type_info. |
| 554 | break; |
| 555 | |
Anders Carlsson | 978ef68 | 2009-12-29 21:58:32 +0000 | [diff] [blame] | 556 | case Type::ConstantArray: |
| 557 | case Type::IncompleteArray: |
Anders Carlsson | c8cfd63 | 2009-12-29 22:30:11 +0000 | [diff] [blame] | 558 | // Itanium C++ ABI 2.9.5p5: |
| 559 | // abi::__array_type_info adds no data members to std::type_info. |
Anders Carlsson | 978ef68 | 2009-12-29 21:58:32 +0000 | [diff] [blame] | 560 | break; |
| 561 | |
Anders Carlsson | 09b6e6e | 2009-12-29 20:20:19 +0000 | [diff] [blame] | 562 | case Type::FunctionNoProto: |
| 563 | case Type::FunctionProto: |
Anders Carlsson | c8cfd63 | 2009-12-29 22:30:11 +0000 | [diff] [blame] | 564 | // Itanium C++ ABI 2.9.5p5: |
| 565 | // abi::__function_type_info adds no data members to std::type_info. |
Anders Carlsson | 09b6e6e | 2009-12-29 20:20:19 +0000 | [diff] [blame] | 566 | break; |
| 567 | |
Anders Carlsson | 9c7b6bb | 2009-12-29 22:13:01 +0000 | [diff] [blame] | 568 | case Type::Enum: |
Anders Carlsson | c8cfd63 | 2009-12-29 22:30:11 +0000 | [diff] [blame] | 569 | // Itanium C++ ABI 2.9.5p5: |
| 570 | // abi::__enum_type_info adds no data members to std::type_info. |
Anders Carlsson | 9c7b6bb | 2009-12-29 22:13:01 +0000 | [diff] [blame] | 571 | break; |
| 572 | |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 573 | case Type::Record: { |
| 574 | const CXXRecordDecl *RD = |
| 575 | cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl()); |
John McCall | 86ff308 | 2010-02-04 22:26:26 +0000 | [diff] [blame] | 576 | if (!RD->hasDefinition() || !RD->getNumBases()) { |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 577 | // We don't need to emit any fields. |
| 578 | break; |
| 579 | } |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 580 | |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 581 | if (CanUseSingleInheritance(RD)) |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 582 | BuildSIClassTypeInfo(RD); |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 583 | else |
| 584 | BuildVMIClassTypeInfo(RD); |
| 585 | |
| 586 | break; |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 587 | } |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 588 | |
| 589 | case Type::ObjCObject: |
| 590 | case Type::ObjCInterface: |
| 591 | BuildObjCObjectTypeInfo(cast<ObjCObjectType>(Ty)); |
| 592 | break; |
| 593 | |
| 594 | case Type::ObjCObjectPointer: |
| 595 | BuildPointerTypeInfo(cast<ObjCObjectPointerType>(Ty)->getPointeeType()); |
| 596 | break; |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 597 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 598 | case Type::Pointer: |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 599 | BuildPointerTypeInfo(cast<PointerType>(Ty)->getPointeeType()); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 600 | break; |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 601 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 602 | case Type::MemberPointer: |
| 603 | BuildPointerToMemberTypeInfo(cast<MemberPointerType>(Ty)); |
| 604 | break; |
| 605 | } |
| 606 | |
| 607 | llvm::Constant *Init = |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 608 | llvm::ConstantStruct::get(VMContext, &Fields[0], Fields.size(), |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 609 | /*Packed=*/false); |
| 610 | |
| 611 | llvm::GlobalVariable *GV = |
| 612 | new llvm::GlobalVariable(CGM.getModule(), Init->getType(), |
| 613 | /*Constant=*/true, Linkage, Init, Name); |
| 614 | |
| 615 | // If there's already an old global variable, replace it with the new one. |
| 616 | if (OldGV) { |
| 617 | GV->takeName(OldGV); |
| 618 | llvm::Constant *NewPtr = |
| 619 | llvm::ConstantExpr::getBitCast(GV, OldGV->getType()); |
| 620 | OldGV->replaceAllUsesWith(NewPtr); |
| 621 | OldGV->eraseFromParent(); |
| 622 | } |
John McCall | cbfe502 | 2010-08-04 08:34:44 +0000 | [diff] [blame] | 623 | |
| 624 | // GCC only relies on the uniqueness of the type names, not the |
| 625 | // type_infos themselves, so we can emit these as hidden symbols. |
| 626 | if (const RecordType *RT = dyn_cast<RecordType>(Ty)) |
| 627 | CGM.setTypeVisibility(GV, cast<CXXRecordDecl>(RT->getDecl()), |
| 628 | /*ForRTTI*/ true); |
| 629 | else if (Linkage == llvm::GlobalValue::WeakODRLinkage) |
| 630 | GV->setVisibility(llvm::GlobalValue::HiddenVisibility); |
| 631 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 632 | return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy); |
| 633 | } |
| 634 | |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 635 | /// ComputeQualifierFlags - Compute the pointer type info flags from the |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 636 | /// given qualifier. |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 637 | static unsigned ComputeQualifierFlags(Qualifiers Quals) { |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 638 | unsigned Flags = 0; |
| 639 | |
| 640 | if (Quals.hasConst()) |
| 641 | Flags |= RTTIBuilder::PTI_Const; |
| 642 | if (Quals.hasVolatile()) |
| 643 | Flags |= RTTIBuilder::PTI_Volatile; |
| 644 | if (Quals.hasRestrict()) |
| 645 | Flags |= RTTIBuilder::PTI_Restrict; |
| 646 | |
| 647 | return Flags; |
| 648 | } |
| 649 | |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 650 | /// BuildObjCObjectTypeInfo - Build the appropriate kind of type_info |
| 651 | /// for the given Objective-C object type. |
| 652 | void RTTIBuilder::BuildObjCObjectTypeInfo(const ObjCObjectType *OT) { |
| 653 | // Drop qualifiers. |
| 654 | const Type *T = OT->getBaseType().getTypePtr(); |
| 655 | assert(isa<BuiltinType>(T) || isa<ObjCInterfaceType>(T)); |
| 656 | |
| 657 | // The builtin types are abi::__class_type_infos and don't require |
| 658 | // extra fields. |
| 659 | if (isa<BuiltinType>(T)) return; |
| 660 | |
| 661 | ObjCInterfaceDecl *Class = cast<ObjCInterfaceType>(T)->getDecl(); |
| 662 | ObjCInterfaceDecl *Super = Class->getSuperClass(); |
| 663 | |
| 664 | // Root classes are also __class_type_info. |
| 665 | if (!Super) return; |
| 666 | |
| 667 | QualType SuperTy = CGM.getContext().getObjCInterfaceType(Super); |
| 668 | |
| 669 | // Everything else is single inheritance. |
| 670 | llvm::Constant *BaseTypeInfo = RTTIBuilder(CGM).BuildTypeInfo(SuperTy); |
| 671 | Fields.push_back(BaseTypeInfo); |
| 672 | } |
| 673 | |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 674 | /// BuildSIClassTypeInfo - Build an abi::__si_class_type_info, used for single |
| 675 | /// inheritance, according to the Itanium C++ ABI, 2.95p6b. |
| 676 | void RTTIBuilder::BuildSIClassTypeInfo(const CXXRecordDecl *RD) { |
| 677 | // Itanium C++ ABI 2.9.5p6b: |
| 678 | // It adds to abi::__class_type_info a single member pointing to the |
| 679 | // type_info structure for the base type, |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 680 | llvm::Constant *BaseTypeInfo = |
| 681 | RTTIBuilder(CGM).BuildTypeInfo(RD->bases_begin()->getType()); |
| 682 | Fields.push_back(BaseTypeInfo); |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 683 | } |
| 684 | |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 685 | /// SeenBases - Contains virtual and non-virtual bases seen when traversing |
| 686 | /// a class hierarchy. |
| 687 | struct SeenBases { |
| 688 | llvm::SmallPtrSet<const CXXRecordDecl *, 16> NonVirtualBases; |
| 689 | llvm::SmallPtrSet<const CXXRecordDecl *, 16> VirtualBases; |
| 690 | }; |
| 691 | |
| 692 | /// ComputeVMIClassTypeInfoFlags - Compute the value of the flags member in |
| 693 | /// abi::__vmi_class_type_info. |
| 694 | /// |
| 695 | static unsigned ComputeVMIClassTypeInfoFlags(const CXXBaseSpecifier *Base, |
| 696 | SeenBases &Bases) { |
| 697 | |
| 698 | unsigned Flags = 0; |
| 699 | |
| 700 | const CXXRecordDecl *BaseDecl = |
| 701 | cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); |
| 702 | |
| 703 | if (Base->isVirtual()) { |
| 704 | if (Bases.VirtualBases.count(BaseDecl)) { |
| 705 | // If this virtual base has been seen before, then the class is diamond |
| 706 | // shaped. |
| 707 | Flags |= RTTIBuilder::VMI_DiamondShaped; |
| 708 | } else { |
| 709 | if (Bases.NonVirtualBases.count(BaseDecl)) |
| 710 | Flags |= RTTIBuilder::VMI_NonDiamondRepeat; |
| 711 | |
| 712 | // Mark the virtual base as seen. |
| 713 | Bases.VirtualBases.insert(BaseDecl); |
| 714 | } |
| 715 | } else { |
| 716 | if (Bases.NonVirtualBases.count(BaseDecl)) { |
| 717 | // If this non-virtual base has been seen before, then the class has non- |
| 718 | // diamond shaped repeated inheritance. |
| 719 | Flags |= RTTIBuilder::VMI_NonDiamondRepeat; |
| 720 | } else { |
| 721 | if (Bases.VirtualBases.count(BaseDecl)) |
| 722 | Flags |= RTTIBuilder::VMI_NonDiamondRepeat; |
| 723 | |
| 724 | // Mark the non-virtual base as seen. |
| 725 | Bases.NonVirtualBases.insert(BaseDecl); |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | // Walk all bases. |
| 730 | for (CXXRecordDecl::base_class_const_iterator I = BaseDecl->bases_begin(), |
| 731 | E = BaseDecl->bases_end(); I != E; ++I) |
| 732 | Flags |= ComputeVMIClassTypeInfoFlags(I, Bases); |
| 733 | |
| 734 | return Flags; |
| 735 | } |
| 736 | |
| 737 | static unsigned ComputeVMIClassTypeInfoFlags(const CXXRecordDecl *RD) { |
| 738 | unsigned Flags = 0; |
| 739 | SeenBases Bases; |
| 740 | |
| 741 | // Walk all bases. |
| 742 | for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), |
| 743 | E = RD->bases_end(); I != E; ++I) |
| 744 | Flags |= ComputeVMIClassTypeInfoFlags(I, Bases); |
| 745 | |
| 746 | return Flags; |
| 747 | } |
| 748 | |
| 749 | /// BuildVMIClassTypeInfo - Build an abi::__vmi_class_type_info, used for |
| 750 | /// classes with bases that do not satisfy the abi::__si_class_type_info |
| 751 | /// constraints, according ti the Itanium C++ ABI, 2.9.5p5c. |
| 752 | void RTTIBuilder::BuildVMIClassTypeInfo(const CXXRecordDecl *RD) { |
| 753 | const llvm::Type *UnsignedIntLTy = |
| 754 | CGM.getTypes().ConvertType(CGM.getContext().UnsignedIntTy); |
| 755 | |
| 756 | // Itanium C++ ABI 2.9.5p6c: |
| 757 | // __flags is a word with flags describing details about the class |
| 758 | // structure, which may be referenced by using the __flags_masks |
| 759 | // enumeration. These flags refer to both direct and indirect bases. |
| 760 | unsigned Flags = ComputeVMIClassTypeInfoFlags(RD); |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 761 | Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, Flags)); |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 762 | |
| 763 | // Itanium C++ ABI 2.9.5p6c: |
| 764 | // __base_count is a word with the number of direct proper base class |
| 765 | // descriptions that follow. |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 766 | Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, RD->getNumBases())); |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 767 | |
| 768 | if (!RD->getNumBases()) |
| 769 | return; |
| 770 | |
| 771 | const llvm::Type *LongLTy = |
| 772 | CGM.getTypes().ConvertType(CGM.getContext().LongTy); |
| 773 | |
| 774 | // Now add the base class descriptions. |
| 775 | |
| 776 | // Itanium C++ ABI 2.9.5p6c: |
| 777 | // __base_info[] is an array of base class descriptions -- one for every |
| 778 | // direct proper base. Each description is of the type: |
| 779 | // |
| 780 | // struct abi::__base_class_type_info { |
| 781 | // public: |
| 782 | // const __class_type_info *__base_type; |
| 783 | // long __offset_flags; |
| 784 | // |
| 785 | // enum __offset_flags_masks { |
| 786 | // __virtual_mask = 0x1, |
| 787 | // __public_mask = 0x2, |
| 788 | // __offset_shift = 8 |
| 789 | // }; |
| 790 | // }; |
| 791 | for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), |
| 792 | E = RD->bases_end(); I != E; ++I) { |
| 793 | const CXXBaseSpecifier *Base = I; |
| 794 | |
| 795 | // The __base_type member points to the RTTI for the base type. |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 796 | Fields.push_back(RTTIBuilder(CGM).BuildTypeInfo(Base->getType())); |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 797 | |
| 798 | const CXXRecordDecl *BaseDecl = |
| 799 | cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); |
| 800 | |
| 801 | int64_t OffsetFlags = 0; |
| 802 | |
| 803 | // All but the lower 8 bits of __offset_flags are a signed offset. |
| 804 | // For a non-virtual base, this is the offset in the object of the base |
| 805 | // subobject. For a virtual base, this is the offset in the virtual table of |
| 806 | // the virtual base offset for the virtual base referenced (negative). |
| 807 | if (Base->isVirtual()) |
Anders Carlsson | af44035 | 2010-03-23 04:11:45 +0000 | [diff] [blame] | 808 | OffsetFlags = CGM.getVTables().getVirtualBaseOffsetOffset(RD, BaseDecl); |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 809 | else { |
| 810 | const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD); |
| 811 | OffsetFlags = Layout.getBaseClassOffset(BaseDecl) / 8; |
| 812 | }; |
| 813 | |
| 814 | OffsetFlags <<= 8; |
| 815 | |
| 816 | // The low-order byte of __offset_flags contains flags, as given by the |
| 817 | // masks from the enumeration __offset_flags_masks. |
| 818 | if (Base->isVirtual()) |
| 819 | OffsetFlags |= BCTI_Virtual; |
| 820 | if (Base->getAccessSpecifier() == AS_public) |
| 821 | OffsetFlags |= BCTI_Public; |
| 822 | |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 823 | Fields.push_back(llvm::ConstantInt::get(LongLTy, OffsetFlags)); |
Anders Carlsson | 0814809 | 2009-12-30 23:47:56 +0000 | [diff] [blame] | 824 | } |
| 825 | } |
| 826 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 827 | /// BuildPointerTypeInfo - Build an abi::__pointer_type_info struct, |
| 828 | /// used for pointer types. |
John McCall | e8dc53e | 2010-08-12 02:17:33 +0000 | [diff] [blame^] | 829 | void RTTIBuilder::BuildPointerTypeInfo(QualType PointeeTy) { |
Anders Carlsson | abd6b09 | 2010-06-02 15:44:35 +0000 | [diff] [blame] | 830 | Qualifiers Quals; |
| 831 | QualType UnqualifiedPointeeTy = |
| 832 | CGM.getContext().getUnqualifiedArrayType(PointeeTy, Quals); |
| 833 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 834 | // Itanium C++ ABI 2.9.5p7: |
| 835 | // __flags is a flag word describing the cv-qualification and other |
| 836 | // attributes of the type pointed to |
Anders Carlsson | abd6b09 | 2010-06-02 15:44:35 +0000 | [diff] [blame] | 837 | unsigned Flags = ComputeQualifierFlags(Quals); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 838 | |
| 839 | // Itanium C++ ABI 2.9.5p7: |
| 840 | // When the abi::__pbase_type_info is for a direct or indirect pointer to an |
| 841 | // incomplete class type, the incomplete target type flag is set. |
Anders Carlsson | abd6b09 | 2010-06-02 15:44:35 +0000 | [diff] [blame] | 842 | if (ContainsIncompleteClassType(UnqualifiedPointeeTy)) |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 843 | Flags |= PTI_Incomplete; |
| 844 | |
| 845 | const llvm::Type *UnsignedIntLTy = |
| 846 | CGM.getTypes().ConvertType(CGM.getContext().UnsignedIntTy); |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 847 | Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, Flags)); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 848 | |
| 849 | // Itanium C++ ABI 2.9.5p7: |
| 850 | // __pointee is a pointer to the std::type_info derivation for the |
| 851 | // unqualified type being pointed to. |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 852 | llvm::Constant *PointeeTypeInfo = |
Anders Carlsson | abd6b09 | 2010-06-02 15:44:35 +0000 | [diff] [blame] | 853 | RTTIBuilder(CGM).BuildTypeInfo(UnqualifiedPointeeTy); |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 854 | Fields.push_back(PointeeTypeInfo); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | /// BuildPointerToMemberTypeInfo - Build an abi::__pointer_to_member_type_info |
| 858 | /// struct, used for member pointer types. |
| 859 | void RTTIBuilder::BuildPointerToMemberTypeInfo(const MemberPointerType *Ty) { |
| 860 | QualType PointeeTy = Ty->getPointeeType(); |
| 861 | |
Anders Carlsson | abd6b09 | 2010-06-02 15:44:35 +0000 | [diff] [blame] | 862 | Qualifiers Quals; |
| 863 | QualType UnqualifiedPointeeTy = |
| 864 | CGM.getContext().getUnqualifiedArrayType(PointeeTy, Quals); |
| 865 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 866 | // Itanium C++ ABI 2.9.5p7: |
| 867 | // __flags is a flag word describing the cv-qualification and other |
| 868 | // attributes of the type pointed to. |
Anders Carlsson | abd6b09 | 2010-06-02 15:44:35 +0000 | [diff] [blame] | 869 | unsigned Flags = ComputeQualifierFlags(Quals); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 870 | |
| 871 | const RecordType *ClassType = cast<RecordType>(Ty->getClass()); |
Anders Carlsson | 17fa6f9 | 2009-12-20 23:37:55 +0000 | [diff] [blame] | 872 | |
| 873 | // Itanium C++ ABI 2.9.5p7: |
| 874 | // When the abi::__pbase_type_info is for a direct or indirect pointer to an |
| 875 | // incomplete class type, the incomplete target type flag is set. |
Anders Carlsson | abd6b09 | 2010-06-02 15:44:35 +0000 | [diff] [blame] | 876 | if (ContainsIncompleteClassType(UnqualifiedPointeeTy)) |
Anders Carlsson | 17fa6f9 | 2009-12-20 23:37:55 +0000 | [diff] [blame] | 877 | Flags |= PTI_Incomplete; |
| 878 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 879 | if (IsIncompleteClassType(ClassType)) |
| 880 | Flags |= PTI_ContainingClassIncomplete; |
| 881 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 882 | const llvm::Type *UnsignedIntLTy = |
| 883 | CGM.getTypes().ConvertType(CGM.getContext().UnsignedIntTy); |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 884 | Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, Flags)); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 885 | |
| 886 | // Itanium C++ ABI 2.9.5p7: |
| 887 | // __pointee is a pointer to the std::type_info derivation for the |
| 888 | // unqualified type being pointed to. |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 889 | llvm::Constant *PointeeTypeInfo = |
Anders Carlsson | abd6b09 | 2010-06-02 15:44:35 +0000 | [diff] [blame] | 890 | RTTIBuilder(CGM).BuildTypeInfo(UnqualifiedPointeeTy); |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 891 | Fields.push_back(PointeeTypeInfo); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 892 | |
| 893 | // Itanium C++ ABI 2.9.5p9: |
| 894 | // __context is a pointer to an abi::__class_type_info corresponding to the |
| 895 | // class type containing the member pointed to |
| 896 | // (e.g., the "A" in "int A::*"). |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 897 | Fields.push_back(RTTIBuilder(CGM).BuildTypeInfo(QualType(ClassType, 0))); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 898 | } |
| 899 | |
John McCall | 9dffe6f | 2010-04-30 01:15:21 +0000 | [diff] [blame] | 900 | llvm::Constant *CodeGenModule::GetAddrOfRTTIDescriptor(QualType Ty, |
| 901 | bool ForEH) { |
| 902 | // Return a bogus pointer if RTTI is disabled, unless it's for EH. |
| 903 | // FIXME: should we even be calling this method if RTTI is disabled |
| 904 | // and it's not for EH? |
| 905 | if (!ForEH && !getContext().getLangOptions().RTTI) { |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 906 | const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext); |
| 907 | return llvm::Constant::getNullValue(Int8PtrTy); |
| 908 | } |
John McCall | 9dffe6f | 2010-04-30 01:15:21 +0000 | [diff] [blame] | 909 | |
Anders Carlsson | 531d55f | 2009-12-31 17:43:53 +0000 | [diff] [blame] | 910 | return RTTIBuilder(*this).BuildTypeInfo(Ty); |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 911 | } |
Rafael Espindola | d1a5c31 | 2010-03-27 02:52:14 +0000 | [diff] [blame] | 912 | |
Rafael Espindola | d1a5c31 | 2010-03-27 02:52:14 +0000 | [diff] [blame] | 913 | void CodeGenModule::EmitFundamentalRTTIDescriptor(QualType Type) { |
| 914 | QualType PointerType = Context.getPointerType(Type); |
| 915 | QualType PointerTypeConst = Context.getPointerType(Type.withConst()); |
| 916 | RTTIBuilder(*this).BuildTypeInfo(Type, true); |
| 917 | RTTIBuilder(*this).BuildTypeInfo(PointerType, true); |
| 918 | RTTIBuilder(*this).BuildTypeInfo(PointerTypeConst, true); |
| 919 | } |
| 920 | |
| 921 | void CodeGenModule::EmitFundamentalRTTIDescriptors() { |
Rafael Espindola | d1a5c31 | 2010-03-27 02:52:14 +0000 | [diff] [blame] | 922 | QualType FundamentalTypes[] = { Context.VoidTy, Context.Char32Ty, |
| 923 | Context.Char16Ty, Context.UnsignedLongLongTy, |
| 924 | Context.LongLongTy, Context.WCharTy, |
| 925 | Context.UnsignedShortTy, Context.ShortTy, |
| 926 | Context.UnsignedLongTy, Context.LongTy, |
| 927 | Context.UnsignedIntTy, Context.IntTy, |
| 928 | Context.UnsignedCharTy, Context.FloatTy, |
| 929 | Context.LongDoubleTy, Context.DoubleTy, |
| 930 | Context.CharTy, Context.BoolTy, |
| 931 | Context.SignedCharTy }; |
| 932 | for (unsigned i = 0; i < sizeof(FundamentalTypes)/sizeof(QualType); ++i) |
| 933 | EmitFundamentalRTTIDescriptor(FundamentalTypes[i]); |
| 934 | } |