cor3ntin updated this revision to Diff 512505. cor3ntin added a comment. Add release note
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148029/new/ https://reviews.llvm.org/D148029 Files: clang/docs/ReleaseNotes.rst clang/include/clang/AST/RawCommentList.h clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/Sema.cpp clang/test/Lexer/comment-escape.c
Index: clang/test/Lexer/comment-escape.c =================================================================== --- clang/test/Lexer/comment-escape.c +++ clang/test/Lexer/comment-escape.c @@ -1,6 +1,38 @@ -// RUN: %clang -fsyntax-only %s +// RUN: %clang -fsyntax-only -Wdocumentation %s // rdar://6757323 // foo \ #define blork 32 +// GH62054 + +/**<*\ +/ +//expected-warning@-2 {{escaped newline between}} \ +//expected-warning@-2 {{line splicing in Doxygen comments are not supported}} + +/**<*\ +/ +//expected-warning@-2 {{escaped newline between}} \ +//expected-warning@-2 {{backslash and newline separated by space}} \ +//expected-warning@-2 {{line splicing in Doxygen comments are not supported}} + + +/*<*\ +/ +//expected-warning@-2 {{escaped newline between}} \ +//expected-warning@-2 {{line splicing in Doxygen comments are not supported}} + +/*<*\ +/ +//expected-warning@-2 {{escaped newline between}} \ +//expected-warning@-2 {{backslash and newline separated by space}} \ +//expected-warning@-2 {{line splicing in Doxygen comments are not supported}} + +/\ +*<**/ +//expected-warning@-2 {{line splicing in Doxygen comments are not supported}} + +/\ +/<* +//expected-warning@-2 {{line splicing in Doxygen comments are not supported}} Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -2390,7 +2390,7 @@ SourceMgr.isInSystemHeader(Comment.getBegin())) return; RawComment RC(SourceMgr, Comment, LangOpts.CommentOpts, false); - if (RC.isAlmostTrailingComment()) { + if (RC.isAlmostTrailingComment() || RC.hasUnsupportedSplice(SourceMgr)) { SourceRange MagicMarkerRange(Comment.getBegin(), Comment.getBegin().getLocWithOffset(3)); StringRef MagicMarkerText; @@ -2401,6 +2401,11 @@ case RawComment::RCK_OrdinaryC: MagicMarkerText = "/**<"; break; + case RawComment::RCK_Invalid: + // FIXME: are there other scenarios that could produce an invalid + // raw comment here? + Diag(Comment.getBegin(), diag::warn_splice_in_doxygen_comment); + return; default: llvm_unreachable("if this is an almost Doxygen comment, " "it should be ordinary"); Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -11377,6 +11377,8 @@ let CategoryName = "Documentation Issue" in { def warn_not_a_doxygen_trailing_member_comment : Warning< "not a Doxygen trailing comment">, InGroup<Documentation>, DefaultIgnore; +def warn_splice_in_doxygen_comment : Warning< + "line splicing in Doxygen comments are not supported">, InGroup<Documentation>, DefaultIgnore; } // end of documentation issue category let CategoryName = "Nullability Issue" in { Index: clang/include/clang/AST/RawCommentList.h =================================================================== --- clang/include/clang/AST/RawCommentList.h +++ clang/include/clang/AST/RawCommentList.h @@ -115,6 +115,17 @@ return extractBriefText(Context); } + bool hasUnsupportedSplice(const SourceManager &SourceMgr) const { + if (!isInvalid()) + return false; + StringRef Text = getRawText(SourceMgr); + if (Text.size() < 6 || Text[0] != '/') + return false; + if (Text[1] == '*') + return Text[Text.size() - 1] != '/' || Text[Text.size() - 2] != '*'; + return Text[1] != '/'; + } + /// Returns sanitized comment text, suitable for presentation in editor UIs. /// E.g. will transform: /// // This is a long multiline comment. Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -290,6 +290,8 @@ (`#61142 <https://github.com/llvm/llvm-project/issues/61142>`_) - Clang now better diagnose placeholder types constrained with a concept that is not a type concept. +- Fix crash when a doc comment contains a line splicing. + (`#62054 <https://github.com/llvm/llvm-project/issues/62054>`_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits