[PATCH] D152525: [clang][Diagnostics] Don't expand label fixit to the next line

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 15 06:59:00 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1aba4a10099: [clang][Diagnostics] Don't expand label fixit to the next line (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D152525?vs=529922&id=531737#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152525/new/

https://reviews.llvm.org/D152525

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/FixIt/fixit-newline-style.c


Index: clang/test/FixIt/fixit-newline-style.c
===================================================================
--- clang/test/FixIt/fixit-newline-style.c
+++ clang/test/FixIt/fixit-newline-style.c
@@ -5,6 +5,7 @@
 // CHECK: warning: unused label 'ddd'
 // CHECK-NEXT: {{^  ddd:}}
 // CHECK-NEXT: {{^  \^~~~$}}
+// CHECK-NOT: {{^  ;}}
 void f(void) {
   ddd:
   ;
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2096,7 +2096,7 @@
   if (isa<LabelDecl>(D)) {
     SourceLocation AfterColon = Lexer::findLocationAfterToken(
         D->getEndLoc(), tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(),
-        true);
+        /*SkipTrailingWhitespaceAndNewline=*/false);
     if (AfterColon.isInvalid())
       return;
     Hint = FixItHint::CreateRemoval(
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -350,6 +350,9 @@
 - Clang no longer diagnoses a read of an empty structure as use of an
   uninitialized variable.
   (`#26842: <https://github.com/llvm/llvm-project/issues/26842>`_)
+- The Fix-It emitted for unused labels used to expand to the next line, which caused
+  visual oddities now that Clang shows more than one line of code snippet. This has
+  been fixed and the Fix-It now only spans to the end of the ``:``.
 
 Bug Fixes in This Version
 -------------------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152525.531737.patch
Type: text/x-patch
Size: 1539 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230615/b54fd796/attachment-0001.bin>


More information about the cfe-commits mailing list