[cfe-commits] r89165 - in /cfe/trunk: lib/CodeGen/CGRtti.cpp test/CodeGenCXX/rtti.cpp

Mike Stump mrs at apple.com
Tue Nov 17 15:45:57 PST 2009


Author: mrs
Date: Tue Nov 17 17:45:57 2009
New Revision: 89165

URL: http://llvm.org/viewvc/llvm-project?rev=89165&view=rev
Log:
Add rtti support for arrays, functiond without prototypes, vectors and
enums.

Modified:
    cfe/trunk/lib/CodeGen/CGRtti.cpp
    cfe/trunk/test/CodeGenCXX/rtti.cpp

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRtti.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRtti.cpp Tue Nov 17 17:45:57 2009
@@ -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");
     }
   }
 };

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

==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti.cpp Tue Nov 17 17:45:57 2009
@@ -189,4 +189,7 @@
   if (typeid(pmd) == typeid(pmf))
     return 1;
   return 0;
+  enum a { };
+  if (typeid(int[5]) == typeid(enum a))
+    return 0;
 }





More information about the cfe-commits mailing list