[cfe-commits] r89416 - in /cfe/trunk/lib/CodeGen: CGCXXExpr.cpp CGRtti.cpp CodeGenModule.h

Mike Stump mrs at apple.com
Thu Nov 19 16:31:51 PST 2009


Author: mrs
Date: Thu Nov 19 18:31:50 2009
New Revision: 89416

URL: http://llvm.org/viewvc/llvm-project?rev=89416&view=rev
Log:
Simplify rtti building code a little.  Prep for reuse for throw rtti
generation.

Modified:
    cfe/trunk/lib/CodeGen/CGCXXExpr.cpp
    cfe/trunk/lib/CodeGen/CGRtti.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXXExpr.cpp Thu Nov 19 18:31:50 2009
@@ -359,7 +359,7 @@
         return Builder.CreateBitCast(CGM.GenerateRttiRef(RD), LTy);
       return Builder.CreateBitCast(CGM.GenerateRtti(RD), LTy);
     }
-    return Builder.CreateBitCast(CGM.GenerateRttiNonClass(Ty), LTy);
+    return Builder.CreateBitCast(CGM.GenerateRtti(Ty), LTy);
   }
   Expr *subE = E->getExprOperand();
   Ty = subE->getType();
@@ -403,7 +403,7 @@
     }      
     return Builder.CreateBitCast(CGM.GenerateRtti(RD), LTy);
   }
-  return Builder.CreateBitCast(CGM.GenerateRttiNonClass(Ty), LTy);
+  return Builder.CreateBitCast(CGM.GenerateRtti(Ty), LTy);
 }
 
 llvm::Value *CodeGenFunction::EmitDynamicCast(llvm::Value *V,

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRtti.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRtti.cpp Thu Nov 19 18:31:50 2009
@@ -260,13 +260,6 @@
     return llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), f);
   }
 
-  llvm::Constant *BuildType2(QualType Ty) {
-    if (const RecordType *RT = Ty.getTypePtr()->getAs<RecordType>())
-      if (const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl()))
-      return Buildclass_type_info(RD);
-    return BuildType(Ty);
-  }
-
   bool DecideExtern(QualType Ty) {
     // For this type, see if all components are never in an anonymous namespace.
     if (const MemberPointerType *MPT = Ty->getAs<MemberPointerType>())
@@ -338,10 +331,10 @@
 
     info.push_back(BuildInt(flags));
     info.push_back(BuildInt(0));
-    info.push_back(BuildType2(PTy));
+    info.push_back(BuildType(PTy));
 
     if (PtrMem)
-      info.push_back(BuildType2(BTy));
+      info.push_back(BuildType(BTy));
 
     // We always generate these as hidden, only the name isn't hidden.
     return finish(info, GV, Name, true, Extern);
@@ -376,6 +369,11 @@
   llvm::Constant *BuildType(QualType Ty) {
     const clang::Type &Type
       = *CGM.getContext().getCanonicalType(Ty).getTypePtr();
+
+    if (const RecordType *RT = Ty.getTypePtr()->getAs<RecordType>())
+      if (const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl()))
+        return Buildclass_type_info(RD);
+
     switch (Type.getTypeClass()) {
     default: {
       assert(0 && "typeid expression");
@@ -426,7 +424,7 @@
   return b.Buildclass_type_info(RD);
 }
 
-llvm::Constant *CodeGenModule::GenerateRttiNonClass(QualType Ty) {
+llvm::Constant *CodeGenModule::GenerateRtti(QualType Ty) {
   RttiBuilder b(*this);
 
   return b.BuildType(Ty);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=89416&r1=89415&r2=89416&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Nov 19 18:31:50 2009
@@ -231,7 +231,7 @@
   llvm::Constant *GenerateRttiRef(const CXXRecordDecl *RD);
   /// GenerateRttiNonClass - Generate the rtti information for the given
   /// non-class type.
-  llvm::Constant *GenerateRttiNonClass(QualType Ty);
+  llvm::Constant *GenerateRtti(QualType Ty);
 
   /// BuildThunk - Build a thunk for the given method
   llvm::Constant *BuildThunk(const CXXMethodDecl *MD, bool Extern, int64_t nv,





More information about the cfe-commits mailing list