diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-14 03:30:27 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-14 03:30:27 +0000 |
commit | 72544f875b8047633806b50a0fcec81d9579574a (patch) | |
tree | 22a617d538f037e26983464e0993d7ace3791775 /clang/lib/Serialization/ASTReaderDecl.cpp | |
parent | bb67af44e18d79a21a26830bfe86d5d8eee06931 (diff) | |
download | bcm5719-llvm-72544f875b8047633806b50a0fcec81d9579574a.tar.gz bcm5719-llvm-72544f875b8047633806b50a0fcec81d9579574a.zip |
[modules] Don't assert if the same imported class template specialization
declaration has its definition instantiated in two sibling modules and they use
a partial specialization.
llvm-svn: 215616
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 46f6106c13a..dcb747fe8d7 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2391,8 +2391,14 @@ static DeclContext *getPrimaryContextForMerging(DeclContext *DC) { if (NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC)) return ND->getOriginalNamespace(); + // There is one tricky case here: if DC is a class with no definition, then + // we're merging a declaration whose definition is added by an update record, + // but we've not yet loaded that update record. In this case, we use the + // canonical declaration for merging until we get a real definition. + // FIXME: When we add a definition, we may need to move the partial lookup + // information from the canonical declaration onto the chosen definition. if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) - return RD->getDefinition(); + return RD->getPrimaryContext(); if (EnumDecl *ED = dyn_cast<EnumDecl>(DC)) return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition() @@ -3361,7 +3367,12 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); auto *TemplArgList = TemplateArgumentList::CreateCopy( Reader.getContext(), TemplArgs.data(), TemplArgs.size()); - Spec->setInstantiationOf(PartialSpec, TemplArgList); + + // FIXME: If we already have a partial specialization set, + // check that it matches. + if (!Spec->getSpecializedTemplateOrPartial() + .is<ClassTemplatePartialSpecializationDecl *>()) + Spec->setInstantiationOf(PartialSpec, TemplArgList); } } |