summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
diff options
context:
space:
mode:
authorJan Korous <jkorous@apple.com>2019-08-13 18:11:44 +0000
committerJan Korous <jkorous@apple.com>2019-08-13 18:11:44 +0000
commitf31d8df1c8c69e7a787c1c1c529a524f3001c66a (patch)
treeb096e87e908a75cd7e77ffbe9762ca3cd11d692e /clang/lib/Serialization/ASTReader.cpp
parentd328954467f406895ba4306eee1109aad6b18797 (diff)
downloadbcm5719-llvm-f31d8df1c8c69e7a787c1c1c529a524f3001c66a.tar.gz
bcm5719-llvm-f31d8df1c8c69e7a787c1c1c529a524f3001c66a.zip
[clang] Refactor doc comments to Decls attribution
- Create ASTContext::attachCommentsToJustParsedDecls so we don't have to load external comments in Sema when trying to attach existing comments to just parsed Decls. - Keep comments ordered and cache their decomposed location - faster SourceLoc-based searching. - Optimize work with redeclarations. - Keep one comment per redeclaration chain (represented by canonical Decl) instead of comment per redeclaration. - For redeclaration chains with no comment attached keep just the last declaration in chain that had no comment instead of every comment-less redeclaration. Differential Revision: https://reviews.llvm.org/D65301 llvm-svn: 368732
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index dc54025fb44..5d6f17e3f0c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -9731,10 +9731,17 @@ void ASTReader::ReadComments() {
}
}
NextCursor:
- // De-serialized SourceLocations get negative FileIDs for other modules,
- // potentially invalidating the original order. Sort it again.
- llvm::sort(Comments, BeforeThanCompare<RawComment>(SourceMgr));
- Context.Comments.addDeserializedComments(Comments);
+ llvm::DenseMap<FileID, std::map<unsigned, RawComment *>>
+ FileToOffsetToComment;
+ for (RawComment *C : Comments) {
+ SourceLocation CommentLoc = C->getBeginLoc();
+ if (CommentLoc.isValid()) {
+ std::pair<FileID, unsigned> Loc =
+ SourceMgr.getDecomposedLoc(CommentLoc);
+ if (Loc.first.isValid())
+ Context.Comments.OrderedComments[Loc.first].emplace(Loc.second, C);
+ }
+ }
}
}
OpenPOWER on IntegriCloud