[cfe-commits] r95340 - in /cfe/trunk/lib: AST/ASTContext.cpp AST/Decl.cpp CodeGen/CodeGenTypes.cpp

John McCall rjmccall at apple.com
Thu Feb 4 17:33:36 PST 2010


Author: rjmccall
Date: Thu Feb  4 19:33:36 2010
New Revision: 95340

URL: http://llvm.org/viewvc/llvm-project?rev=95340&view=rev
Log:
Always start tag definitions before completing them.  Assert same.

Fixes latent and not-so-latent objc++ and blocks++ bugs.


Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=95340&r1=95339&r2=95340&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Feb  4 19:33:36 2010
@@ -2902,6 +2902,7 @@
     CFConstantStringTypeDecl =
       CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
                        &Idents.get("NSConstantString"));
+    CFConstantStringTypeDecl->startDefinition();
 
     QualType FieldTypes[4];
 
@@ -2941,6 +2942,7 @@
     ObjCFastEnumerationStateTypeDecl =
       CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
                        &Idents.get("__objcFastEnumerationState"));
+    ObjCFastEnumerationStateTypeDecl->startDefinition();
 
     QualType FieldTypes[] = {
       UnsignedLongTy,
@@ -2974,6 +2976,7 @@
   // FIXME: Needs the FlagAppleBlock bit.
   T = CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
                        &Idents.get("__block_descriptor"));
+  T->startDefinition();
   
   QualType FieldTypes[] = {
     UnsignedLongTy,
@@ -3017,6 +3020,7 @@
   // FIXME: Needs the FlagAppleBlock bit.
   T = CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
                        &Idents.get("__block_descriptor_withcopydispose"));
+  T->startDefinition();
   
   QualType FieldTypes[] = {
     UnsignedLongTy,
@@ -3137,6 +3141,7 @@
   RecordDecl *T;
   T = CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
                        &Idents.get(Name.str()));
+  T->startDefinition();
   QualType FieldTypes[] = {
     getPointerType(VoidPtrTy),
     IntTy,

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=95340&r1=95339&r2=95340&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Feb  4 19:33:36 2010
@@ -1386,6 +1386,10 @@
 }
 
 void TagDecl::completeDefinition() {
+  assert((!isa<CXXRecordDecl>(this) ||
+          cast<CXXRecordDecl>(this)->hasDefinition()) &&
+         "definition completed but not started");
+
   IsDefinition = true;
   if (TagType *TagT = const_cast<TagType *>(TypeForDecl->getAs<TagType>())) {
     assert(TagT->decl.getPointer() == this &&

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Thu Feb  4 19:33:36 2010
@@ -410,8 +410,8 @@
   if (TDTI != TagDeclTypes.end())
     return TDTI->second;
 
-  // If this is still a forward definition, just define an opaque type to use
-  // for this tagged decl.
+  // If this is still a forward declaration, just define an opaque
+  // type to use for this tagged decl.
   if (!TD->isDefinition()) {
     llvm::Type *ResultType = llvm::OpaqueType::get(getLLVMContext());
     TagDeclTypes.insert(std::make_pair(Key, ResultType));





More information about the cfe-commits mailing list