[llvm-branch-commits] [cfe-branch] r134802 - in /cfe/branches/type-system-rewrite/lib/CodeGen: CGRecordLayoutBuilder.cpp CodeGenTypes.cpp CodeGenTypes.h

Chris Lattner sabre at nondot.org
Fri Jul 8 23:57:17 PDT 2011


Author: lattner
Date: Sat Jul  9 01:57:17 2011
New Revision: 134802

URL: http://llvm.org/viewvc/llvm-project?rev=134802&view=rev
Log:
reimplement addBaseSubobjectTypeName in a more wholesome and compatible
way.

Modified:
    cfe/branches/type-system-rewrite/lib/CodeGen/CGRecordLayoutBuilder.cpp
    cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.cpp
    cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.h

Modified: cfe/branches/type-system-rewrite/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/type-system-rewrite/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=134802&r1=134801&r2=134802&view=diff
==============================================================================
--- cfe/branches/type-system-rewrite/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/branches/type-system-rewrite/lib/CodeGen/CGRecordLayoutBuilder.cpp Sat Jul  9 01:57:17 2011
@@ -601,8 +601,6 @@
 
   llvm::StructType *subobjectType = baseLayout.getBaseSubobjectLLVMType();
   AppendField(baseOffset, subobjectType);
-
-  Types.addBaseSubobjectTypeName(base, baseLayout);
 }
 
 void CGRecordLayoutBuilder::LayoutNonVirtualBase(const CXXRecordDecl *base,
@@ -736,13 +734,14 @@
     FieldTypes.push_back(getByteArrayType(NumBytes));
   }
 
-  BaseSubobjectType = llvm::StructType::get(Types.getLLVMContext(),
-                                            FieldTypes, Packed);
+  
+  BaseSubobjectType = llvm::StructType::createNamed(Types.getLLVMContext(), "",
+                                                    FieldTypes, Packed);
+  Types.addRecordTypeName(RD, BaseSubobjectType, ".base");
 
-  if (needsPadding) {
-    // Pull the padding back off.
+  // Pull the padding back off.
+  if (needsPadding)
     FieldTypes.pop_back();
-  }
 
   return true;
 }

Modified: cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.cpp?rev=134802&r1=134801&r2=134802&view=diff
==============================================================================
--- cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.cpp Sat Jul  9 01:57:17 2011
@@ -44,7 +44,8 @@
     delete &*I++;
 }
 
-void CodeGenTypes::addRecordTypeName(const RecordDecl *RD, const llvm::Type *Ty,
+void CodeGenTypes::addRecordTypeName(const RecordDecl *RD,
+                                     llvm::StructType *Ty,
                                      llvm::StringRef suffix) {
   llvm::SmallString<256> TypeName;
   llvm::raw_svector_ostream OS(TypeName);
@@ -72,12 +73,7 @@
   if (!suffix.empty())
     OS << suffix;
 
-  // FIXME!
-#if 1
-  abort();
-#else
-  TheModule.addTypeName(OS.str(), Ty);
-#endif
+  Ty->setName(OS.str());
 }
 
 /// ConvertTypeForMem - Convert type T into a llvm::Type.  This differs from
@@ -457,17 +453,6 @@
   return *Layout;
 }
 
-void CodeGenTypes::addBaseSubobjectTypeName(const CXXRecordDecl *RD,
-                                            const CGRecordLayout &layout) {
-#if 0
-  llvm::StringRef suffix;
-  if (layout.getBaseSubobjectLLVMType() != layout.getLLVMType())
-    suffix = ".base";
-
-  addRecordTypeName(RD, layout.getBaseSubobjectLLVMType(), suffix);
-#endif
-}
-
 bool CodeGenTypes::isZeroInitializable(QualType T) {
   // No need to check for member pointers when not compiling C++.
   if (!Context.getLangOptions().CPlusPlus)

Modified: cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.h?rev=134802&r1=134801&r2=134802&view=diff
==============================================================================
--- cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/branches/type-system-rewrite/lib/CodeGen/CodeGenTypes.h Sat Jul  9 01:57:17 2011
@@ -108,11 +108,6 @@
   /// and maps llvm::Types to corresponding clang::Type.
   llvm::DenseMap<const Type *, llvm::Type *> TypeCache;
 
-  /// addRecordTypeName - Compute a name from the given record decl with an
-  /// optional suffix and name the given LLVM type using it.
-  void addRecordTypeName(const RecordDecl *RD, const llvm::Type *Ty,
-                         llvm::StringRef suffix);
-
 public:
   CodeGenTypes(ASTContext &Ctx, llvm::Module &M, const llvm::TargetData &TD,
                const ABIInfo &Info, CGCXXABI &CXXABI,
@@ -154,11 +149,6 @@
 
   const CGRecordLayout &getCGRecordLayout(const RecordDecl*);
 
-  /// addBaseSubobjectTypeName - Add a type name for the base subobject of the
-  /// given record layout.
-  void addBaseSubobjectTypeName(const CXXRecordDecl *RD,
-                                const CGRecordLayout &layout);
-
   /// UpdateCompletedType - When we find the full definition for a TagDecl,
   /// replace the 'opaque' type we previously made for it if applicable.
   void UpdateCompletedType(const TagDecl *TD);
@@ -214,6 +204,12 @@
   CGRecordLayout *ComputeRecordLayout(const RecordDecl *D,
                                       llvm::StructType *Ty);
 
+  /// addRecordTypeName - Compute a name from the given record decl with an
+  /// optional suffix and name the given LLVM type using it.
+  void addRecordTypeName(const RecordDecl *RD, llvm::StructType *Ty,
+                         llvm::StringRef suffix);
+  
+
 public:  // These are internal details of CGT that shouldn't be used externally.
   /// ConvertRecordDeclType - Lay out a tagged decl type like struct or union.
   llvm::StructType *ConvertRecordDeclType(const RecordDecl *TD);





More information about the llvm-branch-commits mailing list