Skip to content

Commit d6499e3

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b20c1ffe8f3e' from llvm.org/main into experimental/cas/main
2 parents 8233497 + b20c1ff commit d6499e3

33 files changed

+1414
-432
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ Bug Fixes in This Version
290290
(`#61142 <https://github.com/llvm/llvm-project/issues/61142>`_)
291291
- Clang now better diagnose placeholder types constrained with a concept that is
292292
not a type concept.
293+
- Fix crash when a doc comment contains a line splicing.
294+
(`#62054 <https://github.com/llvm/llvm-project/issues/62054>`_)
293295

294296
Bug Fixes to Compiler Builtins
295297
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/RawCommentList.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ class RawComment {
115115
return extractBriefText(Context);
116116
}
117117

118+
bool hasUnsupportedSplice(const SourceManager &SourceMgr) const {
119+
if (!isInvalid())
120+
return false;
121+
StringRef Text = getRawText(SourceMgr);
122+
if (Text.size() < 6 || Text[0] != '/')
123+
return false;
124+
if (Text[1] == '*')
125+
return Text[Text.size() - 1] != '/' || Text[Text.size() - 2] != '*';
126+
return Text[1] != '/';
127+
}
128+
118129
/// Returns sanitized comment text, suitable for presentation in editor UIs.
119130
/// E.g. will transform:
120131
/// // This is a long multiline comment.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11377,6 +11377,8 @@ def err_coro_invalid_addr_of_label : Error<
1137711377
let CategoryName = "Documentation Issue" in {
1137811378
def warn_not_a_doxygen_trailing_member_comment : Warning<
1137911379
"not a Doxygen trailing comment">, InGroup<Documentation>, DefaultIgnore;
11380+
def warn_splice_in_doxygen_comment : Warning<
11381+
"line splicing in Doxygen comments are not supported">, InGroup<Documentation>, DefaultIgnore;
1138011382
} // end of documentation issue category
1138111383

1138211384
let CategoryName = "Nullability Issue" in {

clang/lib/Sema/Sema.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,7 @@ void Sema::ActOnComment(SourceRange Comment) {
23902390
SourceMgr.isInSystemHeader(Comment.getBegin()))
23912391
return;
23922392
RawComment RC(SourceMgr, Comment, LangOpts.CommentOpts, false);
2393-
if (RC.isAlmostTrailingComment()) {
2393+
if (RC.isAlmostTrailingComment() || RC.hasUnsupportedSplice(SourceMgr)) {
23942394
SourceRange MagicMarkerRange(Comment.getBegin(),
23952395
Comment.getBegin().getLocWithOffset(3));
23962396
StringRef MagicMarkerText;
@@ -2401,6 +2401,11 @@ void Sema::ActOnComment(SourceRange Comment) {
24012401
case RawComment::RCK_OrdinaryC:
24022402
MagicMarkerText = "/**<";
24032403
break;
2404+
case RawComment::RCK_Invalid:
2405+
// FIXME: are there other scenarios that could produce an invalid
2406+
// raw comment here?
2407+
Diag(Comment.getBegin(), diag::warn_splice_in_doxygen_comment);
2408+
return;
24042409
default:
24052410
llvm_unreachable("if this is an almost Doxygen comment, "
24062411
"it should be ordinary");

0 commit comments

Comments
 (0)