[cfe-commits] r92276 - in /cfe/trunk: lib/CodeGen/CGRTTI.cpp test/CodeGenCXX/rtti-linkage.cpp

Anders Carlsson andersca at mac.com
Tue Dec 29 14:13:02 PST 2009


Author: andersca
Date: Tue Dec 29 16:13:01 2009
New Revision: 92276

URL: http://llvm.org/viewvc/llvm-project?rev=92276&view=rev
Log:
Handle enum types as well.

Modified:
    cfe/trunk/lib/CodeGen/CGRTTI.cpp
    cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp

Modified: cfe/trunk/lib/CodeGen/CGRTTI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRTTI.cpp?rev=92276&r1=92275&r2=92276&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRTTI.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRTTI.cpp Tue Dec 29 16:13:01 2009
@@ -370,13 +370,12 @@
     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 @@
       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 @@
     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 @@
     // 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());

Modified: cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp?rev=92276&r1=92275&r2=92276&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp Tue Dec 29 16:13:01 2009
@@ -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 @@
   // 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 @@
   // internal linkage.
   (void)typeid(void (*)() throw (D));
   
+  (void)typeid(E);
+  
   // CHECK: _ZTIN12_GLOBAL__N_11DE to
   return typeid(getD());  
 }





More information about the cfe-commits mailing list