summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RawCommentList.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2014-03-27 15:40:39 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2014-03-27 15:40:39 +0000
commit9ee0e303d68054a8fdb1b071a7de6ddcc8b9ecd9 (patch)
tree74283e009b02f845e8f8b0d14cba0ef054a81666 /clang/lib/AST/RawCommentList.cpp
parenta39fc6dd2afab9cb14286e00f2f6ef2370002c40 (diff)
Comment parsing: when comment ranges are deserialized from multiple modules,
correctly order comments in SourceManager::isBeforeInTranslationUnit() order Unfortunately, this is not as simple as it was implemented previously, and actually requires doing a merge sort. llvm-svn: 204936
Diffstat (limited to 'clang/lib/AST/RawCommentList.cpp')
-rw-r--r--clang/lib/AST/RawCommentList.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
index 586c07654223..24b129a5c532 100644
--- a/clang/lib/AST/RawCommentList.cpp
+++ b/clang/lib/AST/RawCommentList.cpp
@@ -251,3 +251,15 @@ void RawCommentList::addComment(const RawComment &RC,
Comments.push_back(new (Allocator) RawComment(RC));
}
}
+
+void RawCommentList::addDeserializedComments(ArrayRef<RawComment *> DeserializedComments) {
+ std::vector<RawComment *> MergedComments;
+ MergedComments.reserve(Comments.size() + DeserializedComments.size());
+
+ std::merge(Comments.begin(), Comments.end(),
+ DeserializedComments.begin(), DeserializedComments.end(),
+ std::back_inserter(MergedComments),
+ BeforeThanCompare<RawComment>(SourceMgr));
+ std::swap(Comments, MergedComments);
+}
+