Author: dgregor Date: Fri Dec 16 10:34:57 2011 New Revision: 146740 URL: http://llvm.org/viewvc/llvm-project?rev=146740&view=rev Log: If there is a definition of an ObjCInterfaceDecl, make it the Decl returned from the corresponding ObjCInterfaceType
Modified: cfe/trunk/include/clang/AST/Type.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/DeclObjC.cpp Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=146740&r1=146739&r2=146740&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Fri Dec 16 10:34:57 2011 @@ -4139,12 +4139,13 @@ /// - It is its own base type. That is, if T is an ObjCInterfaceType*, /// T->getBaseType() == QualType(T, 0). class ObjCInterfaceType : public ObjCObjectType { - ObjCInterfaceDecl *Decl; + mutable ObjCInterfaceDecl *Decl; ObjCInterfaceType(const ObjCInterfaceDecl *D) : ObjCObjectType(Nonce_ObjCInterface), Decl(const_cast<ObjCInterfaceDecl*>(D)) {} friend class ASTContext; // ASTContext creates these. + friend class ObjCInterfaceDecl; public: /// getDecl - Get the declaration of this interface. Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=146740&r1=146739&r2=146740&view=diff ============================================================================== --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Dec 16 10:34:57 2011 @@ -2819,6 +2819,10 @@ return QualType(PrevDecl->TypeForDecl, 0); } + // Prefer the definition, if there is one. + if (const ObjCInterfaceDecl *Def = Decl->getDefinition()) + Decl = Def; + void *Mem = Allocate(sizeof(ObjCInterfaceType), TypeAlignment); ObjCInterfaceType *T = new (Mem) ObjCInterfaceType(Decl); Decl->TypeForDecl = T; Modified: cfe/trunk/lib/AST/DeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=146740&r1=146739&r2=146740&view=diff ============================================================================== --- cfe/trunk/lib/AST/DeclObjC.cpp (original) +++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Dec 16 10:34:57 2011 @@ -225,7 +225,11 @@ void ObjCInterfaceDecl::allocateDefinitionData() { assert(!hasDefinition() && "ObjC class already has a definition"); Data = new (getASTContext()) DefinitionData(); - Data->Definition = this; + Data->Definition = this; + + // Make the type point at the definition, now that we have one. + if (TypeForDecl) + cast<ObjCInterfaceType>(TypeForDecl)->Decl = this; } void ObjCInterfaceDecl::startDefinition() { _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits