diff options
| author | Jan Korous <jkorous@apple.com> | 2019-08-13 18:11:44 +0000 |
|---|---|---|
| committer | Jan Korous <jkorous@apple.com> | 2019-08-13 18:11:44 +0000 |
| commit | f31d8df1c8c69e7a787c1c1c529a524f3001c66a (patch) | |
| tree | b096e87e908a75cd7e77ffbe9762ca3cd11d692e /clang/lib/Sema | |
| parent | d328954467f406895ba4306eee1109aad6b18797 (diff) | |
| download | bcm5719-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/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 4df0bc12d52..3cda1581b04 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -12465,20 +12465,10 @@ void Sema::ActOnDocumentableDecls(ArrayRef<Decl *> Group) { } } - // See if there are any new comments that are not attached to a decl. - ArrayRef<RawComment *> Comments = Context.getRawCommentList().getComments(); - if (!Comments.empty() && - !Comments.back()->isAttached()) { - // There is at least one comment that not attached to a decl. - // Maybe it should be attached to one of these decls? - // - // Note that this way we pick up not only comments that precede the - // declaration, but also comments that *follow* the declaration -- thanks to - // the lookahead in the lexer: we've consumed the semicolon and looked - // ahead through comments. - for (unsigned i = 0, e = Group.size(); i != e; ++i) - Context.getCommentForDecl(Group[i], &PP); - } + // FIMXE: We assume every Decl in the group is in the same file. + // This is false when preprocessor constructs the group from decls in + // different files (e. g. macros or #include). + Context.attachCommentsToJustParsedDecls(Group, &getPreprocessor()); } /// Common checks for a parameter-declaration that should apply to both function |

