[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
Fri Jun 9 05:19:20 PDT 2023
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, cjdb.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Now that we print >1 line of code snippet, we printed another line of
code for now reason, because the source range we created for the fixit
expanded to the next line, if the next token was there. Don't do that.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152525
Files:
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(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152525.529922.patch
Type: text/x-patch
Size: 890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230609/b3d4af9b/attachment.bin>
More information about the cfe-commits
mailing list