Handle enum types as well.

llvm-svn: 92276
diff --git a/clang/lib/CodeGen/CGRTTI.cpp b/clang/lib/CodeGen/CGRTTI.cpp
index 8680f71..0e3db3a 100644
--- a/clang/lib/CodeGen/CGRTTI.cpp
+++ b/clang/lib/CodeGen/CGRTTI.cpp
@@ -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());