diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-24 02:25:27 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-24 02:25:27 +0000 |
commit | f17fdbd791d78a37cd8f2559247670915d6dcc11 (patch) | |
tree | 91dfccdbca53bb2136418e80ccb9e3be098be8cf /clang/lib/Serialization/ASTReader.cpp | |
parent | 807cf41e2f2f22e0b5d2a2fa63ecb0124c8c97b2 (diff) | |
download | bcm5719-llvm-f17fdbd791d78a37cd8f2559247670915d6dcc11.tar.gz bcm5719-llvm-f17fdbd791d78a37cd8f2559247670915d6dcc11.zip |
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
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
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: { |