]> granicus.if.org Git - clang/commitdiff
Always start tag definitions before completing them. Assert same.
authorJohn McCall <rjmccall@apple.com>
Fri, 5 Feb 2010 01:33:36 +0000 (01:33 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 5 Feb 2010 01:33:36 +0000 (01:33 +0000)
Fixes latent and not-so-latent objc++ and blocks++ bugs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95340 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
lib/AST/Decl.cpp
lib/CodeGen/CodeGenTypes.cpp

index b61ce8e529fd506c176d4c28fd6e799bf9cc4219..4c935139568b1a282430326e62a2220656adc5ad 100644 (file)
@@ -2902,6 +2902,7 @@ QualType ASTContext::getCFConstantStringType() {
     CFConstantStringTypeDecl =
       CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
                        &Idents.get("NSConstantString"));
+    CFConstantStringTypeDecl->startDefinition();
 
     QualType FieldTypes[4];
 
@@ -2941,6 +2942,7 @@ QualType ASTContext::getObjCFastEnumerationStateType() {
     ObjCFastEnumerationStateTypeDecl =
       CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
                        &Idents.get("__objcFastEnumerationState"));
+    ObjCFastEnumerationStateTypeDecl->startDefinition();
 
     QualType FieldTypes[] = {
       UnsignedLongTy,
@@ -2974,6 +2976,7 @@ QualType ASTContext::getBlockDescriptorType() {
   // 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 @@ QualType ASTContext::getBlockDescriptorExtendedType() {
   // 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 @@ QualType ASTContext::getBlockParmType(
   RecordDecl *T;
   T = CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
                        &Idents.get(Name.str()));
+  T->startDefinition();
   QualType FieldTypes[] = {
     getPointerType(VoidPtrTy),
     IntTy,
index ba1def643e1f68018837256a1cd456e107a6431e..a23f28cb37958e7cfe3cac8c1a5de9d7dbb333bf 100644 (file)
@@ -1386,6 +1386,10 @@ void TagDecl::startDefinition() {
 }
 
 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 &&
index e2f45fe076152b64be8be0425fb735accf9b54d7..bcae945adec0d645742bd795367ead1433b36b62 100644 (file)
@@ -410,8 +410,8 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
   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));