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.kirsl...@sony.com> Date: Fri, 13 Jun 2025 21:51:25 +0900 Subject: [PATCH 1/3] [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.kirsl...@sony.com> Date: Fri, 13 Jun 2025 22:08:26 +0900 Subject: [PATCH 2/3] 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; >From 425228fcf90c068dd05620ee4c57e6075e25430a Mon Sep 17 00:00:00 2001 From: Ross Kirsling <ross.kirsl...@sony.com> Date: Sat, 14 Jun 2025 00:31:12 +0900 Subject: [PATCH 3/3] Move test to new file. --- clang/test/FixIt/fixit-punctuator-spelling.cpp | 10 ++++++++++ clang/test/Parser/switch-recovery.cpp | 3 --- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 clang/test/FixIt/fixit-punctuator-spelling.cpp diff --git a/clang/test/FixIt/fixit-punctuator-spelling.cpp b/clang/test/FixIt/fixit-punctuator-spelling.cpp new file mode 100644 index 0000000000000..3cba0e7b64594 --- /dev/null +++ b/clang/test/FixIt/fixit-punctuator-spelling.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s + +void f(int x) { + switch (x) { + case 1 // expected-error {{expected ':' after 'case'}} + break; + } +} +// CHECK: fix-it:"{{.*}}":{6:11-6:11}:":" diff --git a/clang/test/Parser/switch-recovery.cpp b/clang/test/Parser/switch-recovery.cpp index b84c3f0a9865e..40712799933c2 100644 --- a/clang/test/Parser/switch-recovery.cpp +++ b/clang/test/Parser/switch-recovery.cpp @@ -236,9 +236,6 @@ 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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits