[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
ojhunt wrote: The docs failure is #142387 https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik approved this pull request. https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
ojhunt wrote: I can't reproduce this locally so I've ensured my tree is up to date and pushing again to see if it fails again https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.o

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/141148 >From 0db205bb8f6925dd725885395f58a688000c7b8b Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 22 May 2025 02:38:26 -0700 Subject: [PATCH 1/5] [clang] Correct FixIt ranges for unused capture warnings Fixes

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Shafik Yaghmour via cfe-commits
@@ -972,6 +972,12 @@ class Sema final : public SemaBase { /// Calls \c Lexer::getLocForEndOfToken() SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0); + /// Calls \c Lexer::findNextToken() to find the next token, and if the + /// locations of bo

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
ojhunt wrote: > Documentation failure says: > > Warning, treated as error: > /home/runner/work/llvm-project/llvm-project/clang-build/tools/clang/docs/DiagnosticsReference.rst:18009:Unexpected > indentation. Right, but I don't know how/what is causing the failure as I haven't changed any dia

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Erich Keane via cfe-commits
erichkeane wrote: > I don't understand the windows failure (ninja says there was a failure, but I > cannot find any failure in the log?) > > I'm also confused by the documentation failure: it's not telling me > what/where the error is coming from. Documentation failure says: Warning, treat

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/141148 >From 0db205bb8f6925dd725885395f58a688000c7b8b Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 22 May 2025 02:38:26 -0700 Subject: [PATCH 1/5] [clang] Correct FixIt ranges for unused capture warnings Fixes

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
ojhunt wrote: I don't understand the windows failure (ninja says there was a failure, but I cannot find any failure in the log?) I'm also confused by the documentation failure: it's not telling me what/where the error is coming from. https://github.com/llvm/llvm-project/pull/141148 __

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
@@ -1,5 +1,5 @@ // RUN: cp %s %t -// RUN: %clang_cc1 -x c++ -Wunused-lambda-capture -Wno-unused-value -std=c++1z -fixit %t +// RUN: %clang_cc1 -x c++ -Wno-vla-cxx-extension -Wunused-lambda-capture -Wno-unused-value -std=c++1z -fixit %t ojhunt wrote: ah no, th

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread via cfe-commits
@@ -1,5 +1,5 @@ // RUN: cp %s %t -// RUN: %clang_cc1 -x c++ -Wunused-lambda-capture -Wno-unused-value -std=c++1z -fixit %t +// RUN: %clang_cc1 -x c++ -Wno-vla-cxx-extension -Wunused-lambda-capture -Wno-unused-value -std=c++1z -fixit %t cor3ntin wrote: Why is

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread via cfe-commits
@@ -2095,6 +2101,39 @@ FieldDecl *Sema::BuildCaptureField(RecordDecl *RD, return Field; } +static SourceRange +constructFixItRangeForUnusedCapture(Sema &S, SourceRange CaptureRange, cor3ntin wrote: ```suggestion ConstructFixItRangeForUnusedCapture(Sema &S,

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread via cfe-commits
@@ -84,6 +84,29 @@ SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } +SourceRange +Sema::getRangeForNextToken(SourceLocation Loc, bool IncludeMacros, +

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread via cfe-commits
@@ -84,6 +84,21 @@ SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } +SourceRange Sema::getRangeForNextToken(SourceLocation Loc, + bool

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread via cfe-commits
https://github.com/cor3ntin approved this pull request. LGTM modulo nitpicks https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/141148 >From 0db205bb8f6925dd725885395f58a688000c7b8b Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 22 May 2025 02:38:26 -0700 Subject: [PATCH 1/4] [clang] Correct FixIt ranges for unused capture warnings Fixes

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
@@ -0,0 +1,250 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -x c++ -Wunused-lambda-capture -Wno-unused-value -std=c++1z -fixit %t +// RUN: grep -v CHECK %t | FileCheck %s + + +#define MACRO_CAPTURE(...) __VA_ARGS__ +int main() { +int a = 0, b = 0, c = 0; +auto F0 = [a, &b]()

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/141148 >From 0db205bb8f6925dd725885395f58a688000c7b8b Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 22 May 2025 02:38:26 -0700 Subject: [PATCH 1/4] [clang] Correct FixIt ranges for unused capture warnings Fixes

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
@@ -2164,15 +2164,29 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, bool IsLast = (I + 1) == LSI->NumExplicitCaptures; SourceRange FixItRange; if (CaptureRange.isValid()) { +auto GetTrailingEndLocat

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/141148 >From 0db205bb8f6925dd725885395f58a688000c7b8b Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 22 May 2025 02:38:26 -0700 Subject: [PATCH 1/3] [clang] Correct FixIt ranges for unused capture warnings Fixes

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
@@ -972,6 +972,12 @@ class Sema final : public SemaBase { /// Calls \c Lexer::getLocForEndOfToken() SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0); + /// Calls \c Lexer::findNextToken() to find the next token, and if the + /// locations of bo

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
@@ -84,6 +84,21 @@ SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } +SourceRange Sema::getRangeForNextToken(SourceLocation Loc, + bool

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang/test/FixIt/fixit-unused-lambda-capture-traili

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-02 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/141148 >From 0db205bb8f6925dd725885395f58a688000c7b8b Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 22 May 2025 02:38:26 -0700 Subject: [PATCH 1/2] [clang] Correct FixIt ranges for unused capture warnings Fixes

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-30 Thread Oliver Hunt via cfe-commits
@@ -972,6 +972,12 @@ class Sema final : public SemaBase { /// Calls \c Lexer::getLocForEndOfToken() SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0); + /// Calls \c Lexer::findNextToken() to find the next token, and if the + /// locations of bo

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-30 Thread Oliver Hunt via cfe-commits
@@ -84,6 +84,21 @@ SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } +SourceRange Sema::getRangeForNextToken(SourceLocation Loc, + bool

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-30 Thread Oliver Hunt via cfe-commits
@@ -84,6 +84,21 @@ SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } +SourceRange Sema::getRangeForNextToken(SourceLocation Loc, + bool

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-30 Thread Oliver Hunt via cfe-commits
@@ -2164,15 +2164,29 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, bool IsLast = (I + 1) == LSI->NumExplicitCaptures; SourceRange FixItRange; if (CaptureRange.isValid()) { +auto GetTrailingEndLocat

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-30 Thread Oliver Hunt via cfe-commits
@@ -972,6 +972,12 @@ class Sema final : public SemaBase { /// Calls \c Lexer::getLocForEndOfToken() SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0); + /// Calls \c Lexer::findNextToken() to find the next token, and if the + /// locations of bo

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-30 Thread Oliver Hunt via cfe-commits
@@ -0,0 +1,250 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -x c++ -Wunused-lambda-capture -Wno-unused-value -std=c++1z -fixit %t +// RUN: grep -v CHECK %t | FileCheck %s + + +#define MACRO_CAPTURE(...) __VA_ARGS__ +int main() { +int a = 0, b = 0, c = 0; +auto F0 = [a, &b]()

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-27 Thread Shafik Yaghmour via cfe-commits
@@ -972,6 +972,12 @@ class Sema final : public SemaBase { /// Calls \c Lexer::getLocForEndOfToken() SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0); + /// Calls \c Lexer::findNextToken() to find the next token, and if the + /// locations of bo

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-27 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,250 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -x c++ -Wunused-lambda-capture -Wno-unused-value -std=c++1z -fixit %t +// RUN: grep -v CHECK %t | FileCheck %s + + +#define MACRO_CAPTURE(...) __VA_ARGS__ +int main() { +int a = 0, b = 0, c = 0; +auto F0 = [a, &b]()

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-24 Thread Oliver Hunt via cfe-commits
@@ -2164,15 +2164,29 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, bool IsLast = (I + 1) == LSI->NumExplicitCaptures; SourceRange FixItRange; if (CaptureRange.isValid()) { +auto GetTrailingEndLocat

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-24 Thread Oliver Hunt via cfe-commits
@@ -84,6 +84,21 @@ SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } +SourceRange Sema::getRangeForNextToken(SourceLocation Loc, + bool

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-24 Thread Oliver Hunt via cfe-commits
@@ -84,6 +84,21 @@ SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } +SourceRange Sema::getRangeForNextToken(SourceLocation Loc, + bool

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-23 Thread via cfe-commits
@@ -84,6 +84,21 @@ SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } +SourceRange Sema::getRangeForNextToken(SourceLocation Loc, + bool

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-23 Thread via cfe-commits
cor3ntin wrote: This change needs a release note. Please add an entry to `clang/docs/ReleaseNotes.rst` in the section the most adapted to the change, and referencing any Github issue this change fixes. Thanks! https://github.com/llvm/llvm-project/pull/141148 ___

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-23 Thread via cfe-commits
@@ -84,6 +84,21 @@ SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); } +SourceRange Sema::getRangeForNextToken(SourceLocation Loc, + bool

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-23 Thread via cfe-commits
@@ -2164,15 +2164,29 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, bool IsLast = (I + 1) == LSI->NumExplicitCaptures; SourceRange FixItRange; if (CaptureRange.isValid()) { +auto GetTrailingEndLocat

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-22 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Oliver Hunt (ojhunt) Changes Fixes #106445 by using the lexer to find the correct range for the removal FixIts. Previously the ranges that were generated assuming no unsurprising formatting, which for the most part works. Being correct in

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-22 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/141148 Fixes #106445 by using the lexer to find the correct range for the removal FixIts. Previously the ranges that were generated assuming no unsurprising formatting, which for the most part works. Being correct in a