[clang] cf3421d - [Format] Fix a warning

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 15:34:20 PST 2024


In general, if the lambda is only used within its scope, I'd suggest
switching to a default ref capture "[&]" to reduce maintenance burden of
keeping the capture list up to date.

On Thu, Jan 11, 2024 at 12:09 PM Kazu Hirata via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

>
> Author: Kazu Hirata
> Date: 2024-01-11T12:09:01-08:00
> New Revision: cf3421de587d7c947e8f6b5c754393f85a395747
>
> URL:
> https://github.com/llvm/llvm-project/commit/cf3421de587d7c947e8f6b5c754393f85a395747
> DIFF:
> https://github.com/llvm/llvm-project/commit/cf3421de587d7c947e8f6b5c754393f85a395747.diff
>
> LOG: [Format] Fix a warning
>
> This patch fixes:
>
>   clang/unittests/Format/TokenAnnotatorTest.cpp:2181:29: error: lambda
>   capture 'Style' is not used [-Werror,-Wunused-lambda-capture]
>
> Added:
>
>
> Modified:
>     clang/unittests/Format/TokenAnnotatorTest.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp
> b/clang/unittests/Format/TokenAnnotatorTest.cpp
> index 33a320f7bb06e6..1ee209444067d6 100644
> --- a/clang/unittests/Format/TokenAnnotatorTest.cpp
> +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
> @@ -2178,7 +2178,7 @@ TEST_F(TokenAnnotatorTest, UnderstandTableGenTokens)
> {
>
>    TestLexer Lexer(Allocator, Buffers, Style);
>    AdditionalKeywords Keywords(Lexer.IdentTable);
> -  auto Annotate = [&Lexer, &Style](llvm::StringRef Code) {
> +  auto Annotate = [&Lexer](llvm::StringRef Code) {
>      return Lexer.annotate(Code);
>    };
>
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20240117/e2ec8ad4/attachment.html>


More information about the cfe-commits mailing list