[cfe-commits] r46801 - in /cfe/trunk/CodeGen: CodeGenModule.cpp CodeGenModule.h CodeGenTypes.cpp CodeGenTypes.h ModuleBuilder.cpp

Chris Lattner sabre at nondot.org
Tue Feb 5 21:08:19 PST 2008


Author: lattner
Date: Tue Feb  5 23:08:19 2008
New Revision: 46801

URL: http://llvm.org/viewvc/llvm-project?rev=46801&view=rev
Log:
sink more of the type related code into CodeGenTypes.

Modified:
    cfe/trunk/CodeGen/CodeGenModule.cpp
    cfe/trunk/CodeGen/CodeGenModule.h
    cfe/trunk/CodeGen/CodeGenTypes.cpp
    cfe/trunk/CodeGen/CodeGenTypes.h
    cfe/trunk/CodeGen/ModuleBuilder.cpp

Modified: cfe/trunk/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=46801&r1=46800&r2=46801&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenModule.cpp Tue Feb  5 23:08:19 2008
@@ -261,24 +261,9 @@
     EmitGlobalVar(D);
 }
 
-void CodeGenModule::EmitType(const TypeDecl *D) {
-  if (isa<TypedefDecl>(D)) {
-    // TODO: Emit debug info.
-    return;
-  }
-  
-  assert(!isa<ObjCInterfaceDecl>(D) && "FIXME: ADD OBJC SUPPORT");
-  
-  // This must be a tag decl.
-  const TagDecl *TD = cast<TagDecl>(D);
-  
-  // Get the LLVM type for this TagDecl.  If it is non-opaque or if this decl
-  // is still a forward declaration, just return.
-  QualType NewTy = Context.getTagDeclType(const_cast<TagDecl *>(TD));
-  const llvm::Type *T = Types.ConvertType(NewTy);
-  if (isa<llvm::OpaqueType>(T) && TD->isDefinition())
-    // Make sure that this type is translated.
-    Types.ForceTypeCompilation(NewTy);
+void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
+  // Make sure that this type is translated.
+  Types.UpdateCompletedType(TD);
 }
 
 

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

==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/CodeGen/CodeGenModule.h Tue Feb  5 23:08:19 2008
@@ -88,7 +88,7 @@
   void EmitFunction(const FunctionDecl *FD);
   void EmitGlobalVar(const FileVarDecl *D);
   void EmitGlobalVarDeclarator(const FileVarDecl *D);
-  void EmitType(const TypeDecl *D);
+  void UpdateCompletedType(const TagDecl *D);
   llvm::Constant *EmitGlobalInit(const Expr *E);
   llvm::Constant *EmitConstantExpr(const Expr *E);
     

Modified: cfe/trunk/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.cpp?rev=46801&r1=46800&r2=46801&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.cpp Tue Feb  5 23:08:19 2008
@@ -125,11 +125,15 @@
   
 }
 
-/// ForceTypeCompilation - When we find the definition for a type, we require
-/// it to be recompiled, to update the lazy understanding of what it is in our
-/// maps.
-void CodeGenTypes::ForceTypeCompilation(QualType T) {
-  const TagDecl *TD = cast<TagType>(T)->getDecl();
+/// UpdateCompletedType - When we find the full definition for a TagDecl,
+/// replace the 'opaque' type we previously made for it if applicable.
+void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
+  // Get the LLVM type for this TagDecl.  If it is non-opaque or if this decl
+  // is still a forward declaration, just return.
+  QualType NewTy = Context.getTagDeclType(const_cast<TagDecl *>(TD));
+  const llvm::Type *T = ConvertType(NewTy);
+  if (!isa<llvm::OpaqueType>(T))
+    return;
 
   // Remember the opaque LLVM type for this tagdecl.
   llvm::DenseMap<const TagDecl*, llvm::PATypeHolder>::iterator TDTI = 
@@ -141,7 +145,7 @@
   // Remove it from TagDeclTypes so that it will be regenerated.
   TagDeclTypes.erase(TDTI);
 
-  const llvm::Type *NT = ConvertNewType(T);
+  const llvm::Type *NT = ConvertNewType(NewTy);
 
   // If getting the type didn't itself refine it, refine it to its actual type
   // now.

Modified: cfe/trunk/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.h?rev=46801&r1=46800&r2=46801&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.h Tue Feb  5 23:08:19 2008
@@ -138,10 +138,9 @@
   unsigned getLLVMFieldNo(const FieldDecl *FD);
     
   
-  /// ForceTypeCompilation - When we find the definition for a type, we require
-  /// it to be recompiled, to update the lazy understanding of what it is in our
-  /// maps.
-  void ForceTypeCompilation(QualType T);
+  /// 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);
   
 public:  // These are internal details of CGT that shouldn't be used externally.
   void DecodeArgumentTypes(const FunctionTypeProto &FTP, 

Modified: cfe/trunk/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/ModuleBuilder.cpp?rev=46801&r1=46800&r2=46801&view=diff

==============================================================================
--- cfe/trunk/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/CodeGen/ModuleBuilder.cpp Tue Feb  5 23:08:19 2008
@@ -81,7 +81,7 @@
     /// hack on the type, which can occur at any point in the file (because these
     /// can be defined in declspecs).
     virtual void HandleTagDeclDefinition(TagDecl *D) {
-      Builder->EmitType(D);
+      Builder->UpdateCompletedType(D);
     }
     
   };





More information about the cfe-commits mailing list