From f3bccd77fcbe2c06bc0dd8893d222a19cecb9620 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 17 Jan 2012 19:21:53 +0000 Subject: Rework the way in which we (de-)serialize the declarations corresponding to TagType and ObjCInterfaceType. Previously, we would serialize the definition (if available) or the canonical declaration (if no definition was available). However, this can end up forcing the deserialization of the definition even through we might not want to yet. Instead, always serialize the canonical declaration reference in the TagType/ObjCInterfaceType entry, and as part of loading a pending definition, update the "decl" pointer within the type node to point at the definition. This is more robust in hard-to-isolate cases where the *Type gets built and filled in before we see the definition. llvm-svn: 148323 --- clang/lib/Serialization/ASTWriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'clang/lib/Serialization/ASTWriter.cpp') diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 7a09b32ac10..c5f9b2dc88a 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -239,7 +239,7 @@ void ASTTypeWriter::VisitAutoType(const AutoType *T) { void ASTTypeWriter::VisitTagType(const TagType *T) { Record.push_back(T->isDependentType()); - Writer.AddDeclRef(T->getDecl(), Record); + Writer.AddDeclRef(T->getDecl()->getCanonicalDecl(), Record); assert(!T->isBeingDefined() && "Cannot serialize in the middle of a type definition"); } @@ -369,7 +369,7 @@ void ASTTypeWriter::VisitInjectedClassNameType(const InjectedClassNameType *T) { } void ASTTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) { - Writer.AddDeclRef(T->getDecl(), Record); + Writer.AddDeclRef(T->getDecl()->getCanonicalDecl(), Record); Code = TYPE_OBJC_INTERFACE; } -- cgit v1.2.3