]> granicus.if.org Git - clang/commitdiff
Don't add type names for enums; they're never used in LLVM IR.
authorAnders Carlsson <andersca@mac.com>
Wed, 20 Apr 2011 23:51:43 +0000 (23:51 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 20 Apr 2011 23:51:43 +0000 (23:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129894 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenTypes.cpp
lib/CodeGen/CodeGenTypes.h

index f802b0738f6740796765cc7c3b1fe3811f711dbd..255d12f2cc316ea9f6fc081cba0321e2f0558b41 100644 (file)
@@ -65,22 +65,22 @@ void CodeGenTypes::HandleLateResolvedPointers() {
   }
 }
 
-void CodeGenTypes::addTagTypeName(const TagDecl *TD, const llvm::Type *Ty,
-                                  llvm::StringRef suffix) {
+void CodeGenTypes::addRecordTypeName(const RecordDecl *RD, const llvm::Type *Ty,
+                                     llvm::StringRef suffix) {
   llvm::SmallString<256> TypeName;
   llvm::raw_svector_ostream OS(TypeName);
-  OS << TD->getKindName() << '.';
+  OS << RD->getKindName() << '.';
   
   // Name the codegen type after the typedef name
   // if there is no tag type name available
-  if (TD->getIdentifier()) {
+  if (RD->getIdentifier()) {
     // FIXME: We should not have to check for a null decl context here.
     // Right now we do it because the implicit Obj-C decls don't have one.
-    if (TD->getDeclContext())
-      OS << TD->getQualifiedNameAsString();
+    if (RD->getDeclContext())
+      OS << RD->getQualifiedNameAsString();
     else
-      TD->printName(OS);
-  } else if (const TypedefNameDecl *TDD = TD->getTypedefNameForAnonDecl()) {
+      RD->printName(OS);
+  } else if (const TypedefNameDecl *TDD = RD->getTypedefNameForAnonDecl()) {
     // FIXME: We should not have to check for a null decl context here.
     // Right now we do it because the implicit Obj-C decls don't have one.
     if (TDD->getDeclContext())
@@ -403,8 +403,9 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
   case Type::Enum: {
     const TagDecl *TD = cast<TagType>(Ty).getDecl();
     const llvm::Type *Res = ConvertTagDeclType(TD);
-    
-    addTagTypeName(TD, Res, llvm::StringRef());
+
+    if (const RecordDecl *RD = dyn_cast<RecordDecl>(TD))
+      addRecordTypeName(RD, Res, llvm::StringRef());
     return Res;
   }
 
@@ -517,7 +518,7 @@ void CodeGenTypes::addBaseSubobjectTypeName(const CXXRecordDecl *RD,
   if (layout.getBaseSubobjectLLVMType() != layout.getLLVMType())
     suffix = ".base";
 
-  addTagTypeName(RD, layout.getBaseSubobjectLLVMType(), suffix);
+  addRecordTypeName(RD, layout.getBaseSubobjectLLVMType(), suffix);
 }
 
 bool CodeGenTypes::isZeroInitializable(QualType T) {
index a0e1caa6ed73a2f420c812ec68a5c2877729c626..dc383cb4db5d3ddda920ea6d136a2e7cec838dd8 100644 (file)
@@ -101,10 +101,10 @@ private:
   /// used to handle cyclic structures properly.
   void HandleLateResolvedPointers();
 
-  /// addTagTypeName - Compute a name from the given tag decl with an optional
-  /// suffix and name the given LLVM type using it.
-  void addTagTypeName(const TagDecl *TD, const llvm::Type *Ty,
-                      llvm::StringRef suffix);
+  /// 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,