summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index ab0f00b7b98..c5917b66340 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1729,15 +1729,15 @@ ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
static DeclID *newDeclIDList(ASTContext &Context, DeclID *Old,
SmallVectorImpl<DeclID> &IDs) {
assert(!IDs.empty() && "no IDs to add to list");
+ if (Old) {
+ IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
+ std::sort(IDs.begin(), IDs.end());
+ IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
+ }
- size_t OldCount = Old ? *Old : 0;
- size_t NewCount = OldCount + IDs.size();
- auto *Result = new (Context) DeclID[1 + NewCount];
- auto *Pos = Result;
- *Pos++ = NewCount;
- if (OldCount)
- Pos = std::copy(Old + 1, Old + 1 + OldCount, Pos);
- std::copy(IDs.begin(), IDs.end(), Pos);
+ auto *Result = new (Context) DeclID[1 + IDs.size()];
+ *Result = IDs.size();
+ std::copy(IDs.begin(), IDs.end(), Result + 1);
return Result;
}
OpenPOWER on IntegriCloud