Add rtti support for arrays, functiond without prototypes, vectors and
enums.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89165 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGRtti.cpp b/lib/CodeGen/CGRtti.cpp
index 46d7b67..b3872ef 100644
--- a/lib/CodeGen/CGRtti.cpp
+++ b/lib/CodeGen/CGRtti.cpp
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "clang/AST/Type.h"
 #include "clang/AST/RecordLayout.h"
 #include "CodeGenModule.h"
 using namespace clang;
@@ -255,8 +256,6 @@
     if (GV && !GV->isDeclaration())
       return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
 
-    llvm::GlobalVariable::LinkageTypes linktype;
-    linktype = llvm::GlobalValue::LinkOnceODRLinkage;
     std::vector<llvm::Constant *> info;
 
     QualType PTy = Ty->getPointeeType();
@@ -294,7 +293,7 @@
     return finish(info, GV, Out.str());
   }
 
-  llvm::Constant *BuildFunctionType(QualType Ty) {
+  llvm::Constant *BuildSimpleType(QualType Ty, const char *vtbl) {
     llvm::Constant *C;
 
     llvm::SmallString<256> OutName;
@@ -308,16 +307,7 @@
 
     std::vector<llvm::Constant *> info;
 
-    QualType PTy = Ty->getPointeeType();
-    QualType BTy;
-    bool PtrMem = false;
-    if (const MemberPointerType *MPT = dyn_cast<MemberPointerType>(Ty)) {
-      PtrMem = true;
-      BTy = QualType(MPT->getClass(), 0);
-      PTy = MPT->getPointeeType();
-    }
-
-    C = BuildVtableRef("_ZTVN10__cxxabiv120__function_type_infoE");
+    C = BuildVtableRef(vtbl);
     info.push_back(C);
     info.push_back(BuildName(Ty));
       
@@ -329,7 +319,6 @@
       = *CGM.getContext().getCanonicalType(Ty).getTypePtr();
     switch (Type.getTypeClass()) {
     default: {
-      // FIXME: Add all the missing types, such as array...
       assert(0 && "typeid expression");
       return llvm::Constant::getNullValue(Int8PtrTy);
     }
@@ -352,7 +341,16 @@
     case Type::MemberPointer:
       return BuildPointerType(Ty);
     case Type::FunctionProto:
-      return BuildFunctionType(Ty);
+    case Type::FunctionNoProto:
+      return BuildSimpleType(Ty, "_ZTVN10__cxxabiv120__function_type_infoE");
+    case Type::ConstantArray:
+    case Type::IncompleteArray:
+    case Type::VariableArray:
+    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");
     }
   }
 };
diff --git a/test/CodeGenCXX/rtti.cpp b/test/CodeGenCXX/rtti.cpp
index a673544..aea85a3 100644
--- a/test/CodeGenCXX/rtti.cpp
+++ b/test/CodeGenCXX/rtti.cpp
@@ -189,4 +189,7 @@
   if (typeid(pmd) == typeid(pmf))
     return 1;
   return 0;
+  enum a { };
+  if (typeid(int[5]) == typeid(enum a))
+    return 0;
 }