diff options
author | Axel Naumann <Axel.Naumann@cern.ch> | 2012-10-02 09:09:43 +0000 |
---|---|---|
committer | Axel Naumann <Axel.Naumann@cern.ch> | 2012-10-02 09:09:43 +0000 |
commit | 39d26c3e499470cd80a3e6f26f11ac681cd9712c (patch) | |
tree | 29e424007f5364bcd619aa1ecc53eaf0c58e35d7 /lib/Serialization/ASTReader.cpp | |
parent | b7bafa94bc583af9b825b5049aed50359fdb844b (diff) |
Merge pending instantiations instead of overwriting existing ones.
Check whether a pending instantiation needs to be instantiated (or whether an instantiation already exists).
Verify the size of the PendingInstantiations record (was only checking size of existing PendingInstantiations).
Migrate Obj-C++ part of redecl-merge into separate test, now that this is growing.
templates.mm: test that CodeGen has seen exactly one definition of template instantiations.
redecl-merge.m: use "@" specifier for expected-diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164993 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReader.cpp')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 639ef93fb6..a897d868e4 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2223,13 +2223,15 @@ ASTReader::ReadASTBlock(ModuleFile &F) { case PENDING_IMPLICIT_INSTANTIATIONS: if (PendingInstantiations.size() % 2 != 0) { + Error("Invalid existing PendingInstantiations"); + return Failure; + } + + if (Record.size() % 2 != 0) { Error("Invalid PENDING_IMPLICIT_INSTANTIATIONS block"); return Failure; } - - // Later lists of pending instantiations overwrite earlier ones. - // FIXME: This is most certainly wrong for modules. - PendingInstantiations.clear(); + for (unsigned I = 0, N = Record.size(); I != N; /* in loop */) { PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++])); PendingInstantiations.push_back( @@ -5592,7 +5594,11 @@ void ASTReader::ReadPendingInstantiations( ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++])); SourceLocation Loc = SourceLocation::getFromRawEncoding(PendingInstantiations[Idx++]); - Pending.push_back(std::make_pair(D, Loc)); + + // For modules, find out whether an instantiation already exists + if (!getContext().getLangOpts().Modules + || needPendingInstantiation(D)) + Pending.push_back(std::make_pair(D, Loc)); } PendingInstantiations.clear(); } |