From: Chris Lattner Date: Wed, 6 Feb 2008 05:08:19 +0000 (+0000) Subject: sink more of the type related code into CodeGenTypes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5b8806cda286cf41866176ef98011fdaa68da01;p=clang sink more of the type related code into CodeGenTypes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46801 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp index eff26f91b1..e1aec690e9 100644 --- a/CodeGen/CodeGenModule.cpp +++ b/CodeGen/CodeGenModule.cpp @@ -261,24 +261,9 @@ void CodeGenModule::EmitGlobalVarDeclarator(const FileVarDecl *D) { EmitGlobalVar(D); } -void CodeGenModule::EmitType(const TypeDecl *D) { - if (isa(D)) { - // TODO: Emit debug info. - return; - } - - assert(!isa(D) && "FIXME: ADD OBJC SUPPORT"); - - // This must be a tag decl. - const TagDecl *TD = cast(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(TD)); - const llvm::Type *T = Types.ConvertType(NewTy); - if (isa(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); } diff --git a/CodeGen/CodeGenModule.h b/CodeGen/CodeGenModule.h index 900ddf46bb..7c236e0ce8 100644 --- a/CodeGen/CodeGenModule.h +++ b/CodeGen/CodeGenModule.h @@ -88,7 +88,7 @@ public: 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); diff --git a/CodeGen/CodeGenTypes.cpp b/CodeGen/CodeGenTypes.cpp index 2e10cfc971..6ef11dba04 100644 --- a/CodeGen/CodeGenTypes.cpp +++ b/CodeGen/CodeGenTypes.cpp @@ -125,11 +125,15 @@ const llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T) { } -/// 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(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(TD)); + const llvm::Type *T = ConvertType(NewTy); + if (!isa(T)) + return; // Remember the opaque LLVM type for this tagdecl. llvm::DenseMap::iterator TDTI = @@ -141,7 +145,7 @@ void CodeGenTypes::ForceTypeCompilation(QualType T) { // 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. diff --git a/CodeGen/CodeGenTypes.h b/CodeGen/CodeGenTypes.h index b60b9bab3a..2ce718579b 100644 --- a/CodeGen/CodeGenTypes.h +++ b/CodeGen/CodeGenTypes.h @@ -138,10 +138,9 @@ public: 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, diff --git a/CodeGen/ModuleBuilder.cpp b/CodeGen/ModuleBuilder.cpp index 8d3207a19c..50d6fedadd 100644 --- a/CodeGen/ModuleBuilder.cpp +++ b/CodeGen/ModuleBuilder.cpp @@ -81,7 +81,7 @@ namespace { /// 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); } };