diff options
author | David L. Jones <dlj@google.com> | 2018-03-01 23:14:00 +0000 |
---|---|---|
committer | David L. Jones <dlj@google.com> | 2018-03-01 23:14:00 +0000 |
commit | c625fb11d505a486cff77b566823e258e17bb053 (patch) | |
tree | 575481c4ad2e6050eec5177abbe3d71f06fce200 /clang/lib/AST/ASTContext.cpp | |
parent | 1f7314cda7b71e4412d2db8e59dca74913452cf9 (diff) |
Revert r326501 due to buildbot breakage.
Original change:
[NFC] Move CommentOpts checks to the call sites that depend on it.
When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:
1. All comments are saved during parsing, regardless of whether they are doc comments or not.
2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of marking them as ordinary comments. The maybe-doc type of comment is never saved otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are ordinary.
This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 5039be3231b..e93e2ac0c0d 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -226,7 +226,8 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { // for is usually among the last two comments we parsed -- check them // first. RawComment CommentAtDeclLoc( - SourceMgr, SourceRange(DeclLoc), LangOpts.CommentOpts, false); + SourceMgr, SourceRange(DeclLoc), false, + LangOpts.CommentOpts.ParseAllComments); BeforeThanCompare<RawComment> Compare(SourceMgr); ArrayRef<RawComment *>::iterator MaybeBeforeDecl = RawComments.end() - 1; bool Found = Compare(*MaybeBeforeDecl, &CommentAtDeclLoc); @@ -252,8 +253,7 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { // First check whether we have a trailing comment. if (Comment != RawComments.end() && - ((*Comment)->isDocumentation() || LangOpts.CommentOpts.ParseAllComments) - && (*Comment)->isTrailingComment() && + (*Comment)->isDocumentation() && (*Comment)->isTrailingComment() && (isa<FieldDecl>(D) || isa<EnumConstantDecl>(D) || isa<VarDecl>(D) || isa<ObjCMethodDecl>(D) || isa<ObjCPropertyDecl>(D))) { std::pair<FileID, unsigned> CommentBeginDecomp @@ -275,9 +275,7 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { --Comment; // Check that we actually have a non-member Doxygen comment. - if (!((*Comment)->isDocumentation() || - LangOpts.CommentOpts.ParseAllComments) || - (*Comment)->isTrailingComment()) + if (!(*Comment)->isDocumentation() || (*Comment)->isTrailingComment()) return nullptr; // Decompose the end of the comment. @@ -430,7 +428,7 @@ const RawComment *ASTContext::getRawCommentForAnyRedecl( } // If we found a comment, it should be a documentation comment. - assert(!RC || RC->isDocumentation() || LangOpts.CommentOpts.ParseAllComments); + assert(!RC || RC->isDocumentation()); if (OriginalDecl) *OriginalDecl = OriginalDeclForRC; |