From f17fdbd791d78a37cd8f2559247670915d6dcc11 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 24 Apr 2014 02:25:27 +0000 Subject: When two templates get merged together, also merge their pattern declarations together. This is extremely hairy, because in general we need to have loaded both the template and the pattern before we can determine whether either should be merged, so we temporarily violate the rule that all merging happens before reading a decl ends, but *only* in the case where a template's pattern is being loaded while loading the template itself. In order to accomodate this for class templates, delay loading the injected class name type for the pattern of the template until after we've loaded the template itself, if we happen to load the template first. llvm-svn: 207063 --- clang/lib/Serialization/ASTReader.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'clang/lib/Serialization/ASTReader.cpp') diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 44e98f94c8f..834917de1d4 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -5315,8 +5315,14 @@ QualType ASTReader::readTypeRecord(unsigned Index) { QualType TST = readType(*Loc.F, Record, Idx); // probably derivable // FIXME: ASTContext::getInjectedClassNameType is not currently suitable // for AST reading, too much interdependencies. - return - QualType(new (Context, TypeAlignment) InjectedClassNameType(D, TST), 0); + const Type *T; + if (const Type *Existing = D->getTypeForDecl()) + T = Existing; + else if (auto *Prev = D->getPreviousDecl()) + T = Prev->getTypeForDecl(); + else + T = new (Context, TypeAlignment) InjectedClassNameType(D, TST); + return QualType(T, 0); } case TYPE_TEMPLATE_TYPE_PARM: { -- cgit v1.2.3