Handle enum types as well.

llvm-svn: 92276
This commit is contained in:
Anders Carlsson 2009-12-29 22:13:01 +00:00
parent 1c6b864abe
commit ef88695860
2 changed files with 31 additions and 3 deletions

View File

@ -370,13 +370,12 @@ public:
case Type::ConstantArray:
case Type::IncompleteArray:
case Type::VariableArray:
case Type::Enum:
return BuildTypeInfo(Ty);
case Type::Vector:
case Type::ExtVector:
return BuildSimpleType(Ty, "_ZTVN10__cxxabiv117__array_type_infoE");
case Type::Enum:
return BuildSimpleType(Ty, "_ZTVN10__cxxabiv116__enum_type_infoE");
}
}
@ -614,7 +613,17 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(QualType Ty) {
return llvm::GlobalVariable::InternalLinkage;
return llvm::GlobalVariable::WeakODRLinkage;
break;
}
case Type::Enum: {
const EnumType *EnumTy = cast<EnumType>(Ty);
const EnumDecl *ED = EnumTy->getDecl();
// If we're in an anonymous namespace, then we always want internal linkage.
if (ED->isInAnonymousNamespace() || !ED->hasLinkage())
return llvm::GlobalVariable::InternalLinkage;
return llvm::GlobalValue::WeakODRLinkage;
}
case Type::Record: {
@ -694,6 +703,11 @@ void RTTIBuilder::BuildVtablePointer(const Type *Ty) {
VtableName = "_ZTVN10__cxxabiv120__function_type_infoE";
break;
case Type::Enum:
// abi::__enum_type_info
VtableName = "_ZTVN10__cxxabiv116__enum_type_infoE";
break;
case Type::Record: {
const CXXRecordDecl *RD =
cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl());
@ -772,6 +786,11 @@ llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty) {
// abi::__function_type_info adds no data members to std::type_info;
break;
case Type::Enum:
// Itanium C++ ABI 2.9.5p4:
// abi::__enum_type_info adds no data members to std::type_info;
break;
case Type::Record: {
const CXXRecordDecl *RD =
cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl());

View File

@ -38,6 +38,9 @@
// CHECK: _ZTIFvvE = weak_odr
// CHECK: _ZTIPFvvE = weak_odr constant
// CHECK: _ZTSN12_GLOBAL__N_11EE = internal constant
// CHECK: _ZTIN12_GLOBAL__N_11EE = internal constant
// A has no key function, so its RTTI data should be weak_odr.
struct A { };
@ -67,6 +70,10 @@ namespace {
// D is inside an anonymous namespace, so all type information related to D should have
// internal linkage.
struct D { };
// E is also inside an anonymous namespace.
enum E { };
};
const D getD();
@ -80,6 +87,8 @@ const std::type_info &t2() {
// internal linkage.
(void)typeid(void (*)() throw (D));
(void)typeid(E);
// CHECK: _ZTIN12_GLOBAL__N_11DE to
return typeid(getD());
}