diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index bc4771aec77d1..76531a2e07a96 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -243,13 +243,15 @@ RawComment *ASTContext::getRawCommentForDeclNoCacheImpl( LangOpts.CommentOpts.ParseAllComments) && CommentBehindDecl->isTrailingComment() && (isa(D) || isa(D) || isa(D) || - isa(D) || isa(D))) { + isa(D) || isa(D) || + isa(D))) { - // Check that Doxygen trailing comment comes after the declaration, starts - // on the same line and in the same file as the declaration. - if (SourceMgr.getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second) == + // Check that Doxygen trailing comment comes after the declaration and in + // the same file as the declaration. + if (SourceMgr.getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second) <= Comments.getCommentBeginLine(CommentBehindDecl, DeclLocDecomp.first, OffsetCommentBehindDecl->first)) { + return CommentBehindDecl; } }