[clang] [Clang] Fix fix-it hint regression from #143460 (PR #144069)
Ross Kirsling via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 13 06:08:36 PDT 2025
https://github.com/rkirsling updated https://github.com/llvm/llvm-project/pull/144069
>From be121c500684e971ad696be8d53db732665d851c Mon Sep 17 00:00:00 2001
From: Ross Kirsling <ross.kirsling at sony.com>
Date: Fri, 13 Jun 2025 21:51:25 +0900
Subject: [PATCH 1/2] [Clang] Fix fix-it hint regression from #143460
`:` began displaying as `colon` in the fix-it hint for a `case` with a missing colon.
---
clang/lib/Parse/ParseStmt.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 434ea68442819..c0c9bbc2e15c6 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -836,8 +836,7 @@ StmtResult Parser::ParseCaseStatement(ParsedStmtContext StmtCtx,
Diag(ExpectedLoc, diag::err_expected_after)
<< "'case'" << tok::colon
- << FixItHint::CreateInsertion(ExpectedLoc,
- tok::getTokenName(tok::colon));
+ << FixItHint::CreateInsertion(ExpectedLoc, ":");
ColonLoc = ExpectedLoc;
}
>From 26f4db70221b106b286566c1434530848567e849 Mon Sep 17 00:00:00 2001
From: Ross Kirsling <ross.kirsling at sony.com>
Date: Fri, 13 Jun 2025 22:08:26 +0900
Subject: [PATCH 2/2] Update test case.
---
clang/test/Parser/switch-recovery.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/test/Parser/switch-recovery.cpp b/clang/test/Parser/switch-recovery.cpp
index 40712799933c2..b84c3f0a9865e 100644
--- a/clang/test/Parser/switch-recovery.cpp
+++ b/clang/test/Parser/switch-recovery.cpp
@@ -236,6 +236,9 @@ namespace GH143216 {
int f(int x) {
switch (x) {
case FOO // expected-error {{expected ':' after 'case'}}
+ // CHECK: {{^}} case FOO
+ // CHECK: {{^}} ^
+ // CHECK: {{^}} :
return 0;
default:
return 1;
More information about the cfe-commits
mailing list