diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 451835f8bb39a..336bd5b6aa2e1 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -350,6 +350,9 @@ Improvements to Clang's diagnostics - Clang no longer diagnoses a read of an empty structure as use of an uninitialized variable. (`#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 ------------------------- diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index b1436ba50892a..757c4c310be3d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2096,7 +2096,7 @@ static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, if (isa(D)) { SourceLocation AfterColon = Lexer::findLocationAfterToken( D->getEndLoc(), tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(), - true); + /*SkipTrailingWhitespaceAndNewline=*/false); if (AfterColon.isInvalid()) return; Hint = FixItHint::CreateRemoval( diff --git a/clang/test/FixIt/fixit-newline-style.c b/clang/test/FixIt/fixit-newline-style.c index 091b79426bcdf..06cb262691ea0 100644 --- a/clang/test/FixIt/fixit-newline-style.c +++ b/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: ;