diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2014-03-27 15:40:39 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2014-03-27 15:40:39 +0000 |
commit | 9ee0e303d68054a8fdb1b071a7de6ddcc8b9ecd9 (patch) | |
tree | 74283e009b02f845e8f8b0d14cba0ef054a81666 /clang/lib/AST/RawCommentList.cpp | |
parent | a39fc6dd2afab9cb14286e00f2f6ef2370002c40 (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.cpp | 12 |
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); +} + |