[cfe-commits] r85555 - in /cfe/trunk/lib/CodeGen: CGRtti.cpp Mangle.cpp Mangle.h

Anders Carlsson andersca at mac.com
Thu Oct 29 18:26:13 PDT 2009


Author: andersca
Date: Thu Oct 29 20:26:12 2009
New Revision: 85555

URL: http://llvm.org/viewvc/llvm-project?rev=85555&view=rev
Log:
mangleCXXRtti obviously needs to take a type, what was I thinking...

Modified:
    cfe/trunk/lib/CodeGen/CGRtti.cpp
    cfe/trunk/lib/CodeGen/Mangle.cpp
    cfe/trunk/lib/CodeGen/Mangle.h

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRtti.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRtti.cpp Thu Oct 29 20:26:12 2009
@@ -16,32 +16,32 @@
 using namespace CodeGen;
 
 llvm::Constant *CodeGenModule::GenerateRtti(const CXXRecordDecl *RD) {
-  llvm::Type *Ptr8Ty;
-  Ptr8Ty = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
-  llvm::Constant *Rtti = llvm::Constant::getNullValue(Ptr8Ty);
+  const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
 
   if (!getContext().getLangOptions().Rtti)
-    return Rtti;
+    return llvm::Constant::getNullValue(Int8PtrTy);
 
   llvm::SmallString<256> OutName;
   llvm::raw_svector_ostream Out(OutName);
-  mangleCXXRtti(getMangleContext(), RD, Out);
+  mangleCXXRtti(getMangleContext(), 
+                Context.getTagDeclType(RD).getTypePtr(), Out);
   
   llvm::GlobalVariable::LinkageTypes linktype;
   linktype = llvm::GlobalValue::WeakAnyLinkage;
   std::vector<llvm::Constant *> info;
   // assert(0 && "FIXME: implement rtti descriptor");
   // FIXME: descriptor
-  info.push_back(llvm::Constant::getNullValue(Ptr8Ty));
+  info.push_back(llvm::Constant::getNullValue(Int8PtrTy));
   // assert(0 && "FIXME: implement rtti ts");
   // FIXME: TS
-  info.push_back(llvm::Constant::getNullValue(Ptr8Ty));
+  info.push_back(llvm::Constant::getNullValue(Int8PtrTy));
 
   llvm::Constant *C;
-  llvm::ArrayType *type = llvm::ArrayType::get(Ptr8Ty, info.size());
+  llvm::ArrayType *type = llvm::ArrayType::get(Int8PtrTy, info.size());
   C = llvm::ConstantArray::get(type, info);
-  Rtti = new llvm::GlobalVariable(getModule(), type, true, linktype, C,
-                                  Out.str());
-  Rtti = llvm::ConstantExpr::getBitCast(Rtti, Ptr8Ty);
+  llvm::Constant *Rtti = 
+    new llvm::GlobalVariable(getModule(), type, true, linktype, C,
+                             Out.str());
+  Rtti = llvm::ConstantExpr::getBitCast(Rtti, Int8PtrTy);
   return Rtti;
 }

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

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Thu Oct 29 20:26:12 2009
@@ -53,7 +53,7 @@
 
     void mangleCXXVtable(const CXXRecordDecl *RD);
     void mangleCXXVTT(const CXXRecordDecl *RD);
-    void mangleCXXRtti(const CXXRecordDecl *RD);
+    void mangleCXXRtti(const Type *Ty);
     void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type);
     void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type);
 
@@ -212,10 +212,12 @@
   mangleName(RD);
 }
 
-void CXXNameMangler::mangleCXXRtti(const CXXRecordDecl *RD) {
+void CXXNameMangler::mangleCXXRtti(const Type *Ty) {
   // <special-name> ::= TI <type>  # typeinfo structure
   Out << "_ZTI";
-  mangleName(RD);
+
+  // FIXME: mangleType should probably take a const Type * instead.
+  mangleType(QualType(Ty, 0));
 }
 
 void CXXNameMangler::mangleGuardVariable(const VarDecl *D) {
@@ -1432,10 +1434,10 @@
     os.flush();
   }
 
-  void mangleCXXRtti(MangleContext &Context, const CXXRecordDecl *RD,
+  void mangleCXXRtti(MangleContext &Context, const Type *Ty,
                      llvm::raw_ostream &os) {
     CXXNameMangler Mangler(Context, os);
-    Mangler.mangleCXXRtti(RD);
+    Mangler.mangleCXXRtti(Ty);
 
     os.flush();
   }

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

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.h (original)
+++ cfe/trunk/lib/CodeGen/Mangle.h Thu Oct 29 20:26:12 2009
@@ -67,7 +67,7 @@
                        llvm::raw_ostream &os);
   void mangleCXXVTT(MangleContext &Context, const CXXRecordDecl *RD,
                        llvm::raw_ostream &os);
-  void mangleCXXRtti(MangleContext &Context, const CXXRecordDecl *RD, 
+  void mangleCXXRtti(MangleContext &Context, const Type *T, 
                      llvm::raw_ostream &os);
   void mangleCXXCtor(MangleContext &Context, const CXXConstructorDecl *D, 
                      CXXCtorType Type, llvm::raw_ostream &os);





More information about the cfe-commits mailing list