[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp marked an inline comment as done. carlosgalvezp added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.h:1 +//===--- MisleadingCaptureDefaultByValueCheck.h - clang-tidy*- C++ +//-*-===// Eugene.Zelenko wrote: > Split header comment. Thanks, fixed in an NFC patch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.h:1 +//===--- MisleadingCaptureDefaultByValueCheck.h - clang-tidy*- C++ +//-*-===// Split header comment. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
This revision was automatically updated to reflect the committed changes. Closed by commit rGeedbe81b1c6d: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this… (authored by carlosgalvezp). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 Files: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.h clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-capture-default-when-capturing-this.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/misleading-capture-default-by-value.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp === --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp @@ -1,7 +1,4 @@ -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -check-suffixes=,DEFAULT -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-avoid-capture-default-when-capturing-this.IgnoreCaptureDefaultByReference, value: true}]}" +// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-misleading-capture-default-by-value %t struct Obj { void lambdas_that_warn_default_capture_copy() { @@ -9,73 +6,60 @@ int local2{}; auto explicit_this_capture = [=, this]() { }; -// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture = [this]() { }; auto explicit_this_capture_locals1 = [=, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_locals1 = [local, this]() { return (local+x) > 10; }; auto explicit_this_capture_locals2 = [=, this]() { return (local+local2) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_locals2 = [local, local2, this]() { return (local+local2) > 10; }; auto explicit_this_capture_local_ref = [=, this, &local]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_local_ref = [this, &local]() { return (local+x) > 10; }; auto explicit_this_capture_local_ref2 = [=, &local, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-defaul
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp updated this revision to Diff 513875. carlosgalvezp added a comment. Remove excessive whitespace Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 Files: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.h clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-capture-default-when-capturing-this.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/misleading-capture-default-by-value.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp === --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp @@ -1,7 +1,4 @@ -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -check-suffixes=,DEFAULT -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-avoid-capture-default-when-capturing-this.IgnoreCaptureDefaultByReference, value: true}]}" +// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-misleading-capture-default-by-value %t struct Obj { void lambdas_that_warn_default_capture_copy() { @@ -9,73 +6,60 @@ int local2{}; auto explicit_this_capture = [=, this]() { }; -// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture = [this]() { }; auto explicit_this_capture_locals1 = [=, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_locals1 = [local, this]() { return (local+x) > 10; }; auto explicit_this_capture_locals2 = [=, this]() { return (local+local2) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_locals2 = [local, local2, this]() { return (local+local2) > 10; }; auto explicit_this_capture_local_ref = [=, this, &local]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_local_ref = [this, &local]() { return (local+x) > 10; }; auto explicit_this_capture_local_ref2 = [=, &local, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_local_ref2 = [&local, this]() { return (loca
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp updated this revision to Diff 513874. carlosgalvezp added a comment. Fix check ordering. Align check documentation across header, .rst file and Release Notes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 Files: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.h clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-capture-default-when-capturing-this.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/misleading-capture-default-by-value.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp === --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp @@ -1,7 +1,4 @@ -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -check-suffixes=,DEFAULT -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-avoid-capture-default-when-capturing-this.IgnoreCaptureDefaultByReference, value: true}]}" +// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-misleading-capture-default-by-value %t struct Obj { void lambdas_that_warn_default_capture_copy() { @@ -9,73 +6,60 @@ int local2{}; auto explicit_this_capture = [=, this]() { }; -// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture = [this]() { }; auto explicit_this_capture_locals1 = [=, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_locals1 = [local, this]() { return (local+x) > 10; }; auto explicit_this_capture_locals2 = [=, this]() { return (local+local2) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_locals2 = [local, local2, this]() { return (local+local2) > 10; }; auto explicit_this_capture_local_ref = [=, this, &local]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_local_ref = [this, &local]() { return (local+x) > 10; }; auto explicit_this_capture_local_ref2 = [=, &local, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto exp
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp updated this revision to Diff 513873. carlosgalvezp marked 2 inline comments as done. carlosgalvezp added a comment. Rename check to latest proposal Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 Files: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.h clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-capture-default-when-capturing-this.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/misleading-capture-default-by-value.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp === --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/misleading-capture-default-by-value.cpp @@ -1,7 +1,4 @@ -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -check-suffixes=,DEFAULT -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-avoid-capture-default-when-capturing-this.IgnoreCaptureDefaultByReference, value: true}]}" +// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-misleading-capture-default-by-value %t struct Obj { void lambdas_that_warn_default_capture_copy() { @@ -9,73 +6,60 @@ int local2{}; auto explicit_this_capture = [=, this]() { }; -// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture = [this]() { }; auto explicit_this_capture_locals1 = [=, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_locals1 = [local, this]() { return (local+x) > 10; }; auto explicit_this_capture_locals2 = [=, this]() { return (local+local2) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_locals2 = [local, local2, this]() { return (local+local2) > 10; }; auto explicit_this_capture_local_ref = [=, this, &local]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_capture_local_ref = [this, &local]() { return (local+x) > 10; }; auto explicit_this_capture_local_ref2 = [=, &local, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-misleading-capture-default-by-value] // CHECK-FIXES: auto explicit_this_
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
PiotrZSL added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp:55 +AvoidByValueCaptureDefaultWhenCapturingThisCheck>( + "cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this"); CheckFactories.registerCheck( PiotrZSL wrote: > carlosgalvezp wrote: > > PiotrZSL wrote: > > > carlosgalvezp wrote: > > > > PiotrZSL wrote: > > > > > PiotrZSL wrote: > > > > > > this name is hard to understand > > > > > > > > > > > > I asked ChatGPT about it, and here are some other proposals: > > > > > > > > > > > > - cppcoreguidelines-avoid-by-value-default-this-capture > > > > > > - cppcoreguidelines-avoid-this-capture-by-value-default > > > > > > - cppcoreguidelines-explicit-this-capture-by-value > > > > > > - cppcoreguidelines-implicit-this-capture-by-value > > > > > > - cppcoreguidelines-implicit-by-value-this-capture > > > > > > - cppcoreguidelines-prefer-explicit-this-capture > > > > > > - cppcoreguidelines-avoid-ambiguous-this-capture > > > > > Probably something like this would be good: > > > > > cppcoreguidelines-avoid-implicit-this-capture-by-value > > > > Nice suggestions! I've done a bit of mix of them, let me know if you > > > > are happy with it. > > > To be honest that "default" sounds strange. Simply I check name does not > > > read as an "sentence", more as bunch of words, but I'm fine with this. > > I agree, I'm not very happy either. We had quite a lot of discussion in the > > original patch about this. The problem is that the Standard calls it > > "capture default" which doesn't read like an English sentence (should be > > "default capture"). But it seems "capture default" is a widely used term > > out there and in the repo, so that's why we went for that. > > > > What about the following? > > > > - cppcoreguidelines-ambiguous-capture-default-by-value > > - cppcoreguidelines-ambiguous-by-value-capture-default > GPT: "Both of these names convey the intended meaning, but the latter option, > cppcoreguidelines-ambiguous-capture-default-by-value, is slightly clearer and > more readable. It emphasizes that the ambiguity is related to the > "capture-default" and its "by-value" aspect. This makes it easier for someone > to understand the rule's purpose at a glance." > > ME: "is word ambiguous correct here ?" > > GPT: "The word "ambiguous" may not be the most accurate term to describe the > issue in this context. A better term might be "misleading" since the behavior > of by-value capture-defaults in member functions can lead to confusion or > incorrect assumptions about how data members are captured. > > Thus, a more appropriate name for the guideline could be > cppcoreguidelines-misleading-capture-default-by-value. This name highlights > that the capture-default by value can be misleading in terms of how data > members are captured within member functions." But probably we can stay with current name, there is not much that we can do. In future we can always change it to something else... Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
PiotrZSL added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp:55 +AvoidByValueCaptureDefaultWhenCapturingThisCheck>( + "cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this"); CheckFactories.registerCheck( carlosgalvezp wrote: > PiotrZSL wrote: > > carlosgalvezp wrote: > > > PiotrZSL wrote: > > > > PiotrZSL wrote: > > > > > this name is hard to understand > > > > > > > > > > I asked ChatGPT about it, and here are some other proposals: > > > > > > > > > > - cppcoreguidelines-avoid-by-value-default-this-capture > > > > > - cppcoreguidelines-avoid-this-capture-by-value-default > > > > > - cppcoreguidelines-explicit-this-capture-by-value > > > > > - cppcoreguidelines-implicit-this-capture-by-value > > > > > - cppcoreguidelines-implicit-by-value-this-capture > > > > > - cppcoreguidelines-prefer-explicit-this-capture > > > > > - cppcoreguidelines-avoid-ambiguous-this-capture > > > > Probably something like this would be good: > > > > cppcoreguidelines-avoid-implicit-this-capture-by-value > > > Nice suggestions! I've done a bit of mix of them, let me know if you are > > > happy with it. > > To be honest that "default" sounds strange. Simply I check name does not > > read as an "sentence", more as bunch of words, but I'm fine with this. > I agree, I'm not very happy either. We had quite a lot of discussion in the > original patch about this. The problem is that the Standard calls it "capture > default" which doesn't read like an English sentence (should be "default > capture"). But it seems "capture default" is a widely used term out there and > in the repo, so that's why we went for that. > > What about the following? > > - cppcoreguidelines-ambiguous-capture-default-by-value > - cppcoreguidelines-ambiguous-by-value-capture-default GPT: "Both of these names convey the intended meaning, but the latter option, cppcoreguidelines-ambiguous-capture-default-by-value, is slightly clearer and more readable. It emphasizes that the ambiguity is related to the "capture-default" and its "by-value" aspect. This makes it easier for someone to understand the rule's purpose at a glance." ME: "is word ambiguous correct here ?" GPT: "The word "ambiguous" may not be the most accurate term to describe the issue in this context. A better term might be "misleading" since the behavior of by-value capture-defaults in member functions can lead to confusion or incorrect assumptions about how data members are captured. Thus, a more appropriate name for the guideline could be cppcoreguidelines-misleading-capture-default-by-value. This name highlights that the capture-default by value can be misleading in terms of how data members are captured within member functions." Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp marked 3 inline comments as done. carlosgalvezp added a comment. > To be honest for me this check still looks too strict, for example it will > warn when we capture this explicitly, and we don't use any class fields, but > we use some local variables captured by value and for example call some other > class method using that this pointer. That's a good point, I would agree that in that case it would not be confusing. Maybe you can bring it up for discussion to them? My proposal got accepted :) Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidValueCaptureDefaultThisCheck.h:17-25 +/// Warns when lambda specify a by-value capture default and capture ``this``. +/// The check also offers fix-its. /// -/// Capture defaults in lambas defined within member functions can be +/// By-value capture defaults in lambas defined within member functions can be /// misleading about whether capturing data member is by value or reference. /// For example, [=] will capture local variables by value but member variables +/// by reference. CppCoreGuideline F.54 suggests to never use by-value capture PiotrZSL wrote: > thats too much information for an check short description. > Sure, I can fix in a separate NFC patch. I'd like to focus on matching functionality against the updated rules in this patch. Comment at: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-value-capture-default-this.rst:11 specifying the capture default ``[=]`` will still capture data members by reference. PiotrZSL wrote: > Note: I'm missing here explanation why. (yes I know that this may not be > related) > > Maybe: > "By-value capture-defaults in member functions can be misleading about > whether data members are captured by value or reference. This occurs because > specifying the capture default [=] actually captures the this pointer by > value, not the data members themselves. As a result, data members are still > indirectly accessed via the captured this pointer, which essentially means > they are being accessed by reference. Therefore, even when using [=], data > members are effectively captured by reference, which might not align with the > user's expectations." Good point, I can fix in a separate patch together with your previous comment! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp:55 +AvoidByValueCaptureDefaultWhenCapturingThisCheck>( + "cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this"); CheckFactories.registerCheck( PiotrZSL wrote: > carlosgalvezp wrote: > > PiotrZSL wrote: > > > PiotrZSL wrote: > > > > this name is hard to understand > > > > > > > > I asked ChatGPT about it, and here are some other proposals: > > > > > > > > - cppcoreguidelines-avoid-by-value-default-this-capture > > > > - cppcoreguidelines-avoid-this-capture-by-value-default > > > > - cppcoreguidelines-explicit-this-capture-by-value > > > > - cppcoreguidelines-implicit-this-capture-by-value > > > > - cppcoreguidelines-implicit-by-value-this-capture > > > > - cppcoreguidelines-prefer-explicit-this-capture > > > > - cppcoreguidelines-avoid-ambiguous-this-capture > > > Probably something like this would be good: > > > cppcoreguidelines-avoid-implicit-this-capture-by-value > > Nice suggestions! I've done a bit of mix of them, let me know if you are > > happy with it. > To be honest that "default" sounds strange. Simply I check name does not read > as an "sentence", more as bunch of words, but I'm fine with this. I agree, I'm not very happy either. We had quite a lot of discussion in the original patch about this. The problem is that the Standard calls it "capture default" which doesn't read like an English sentence (should be "default capture"). But it seems "capture default" is a widely used term out there and in the repo, so that's why we went for that. What about the following? - cppcoreguidelines-ambiguous-capture-default-by-value - cppcoreguidelines-ambiguous-by-value-capture-default Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
PiotrZSL accepted this revision. PiotrZSL added a comment. This revision is now accepted and ready to land. Just some minor issues in documentation. To be honest for me this check still looks too strict, for example it will warn when we capture `this` explicitly, and we don't use any class fields, but we use some local variables captured by value and for example call some other class method using that this pointer. But well, i'm not fan of cppcoreguidelines, I justt fell that most of rules there are not 100% implementable in a normal project. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidValueCaptureDefaultThisCheck.h:17-25 +/// Warns when lambda specify a by-value capture default and capture ``this``. +/// The check also offers fix-its. /// -/// Capture defaults in lambas defined within member functions can be +/// By-value capture defaults in lambas defined within member functions can be /// misleading about whether capturing data member is by value or reference. /// For example, [=] will capture local variables by value but member variables +/// by reference. CppCoreGuideline F.54 suggests to never use by-value capture thats too much information for an check short description. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp:55 +AvoidByValueCaptureDefaultWhenCapturingThisCheck>( + "cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this"); CheckFactories.registerCheck( carlosgalvezp wrote: > PiotrZSL wrote: > > PiotrZSL wrote: > > > this name is hard to understand > > > > > > I asked ChatGPT about it, and here are some other proposals: > > > > > > - cppcoreguidelines-avoid-by-value-default-this-capture > > > - cppcoreguidelines-avoid-this-capture-by-value-default > > > - cppcoreguidelines-explicit-this-capture-by-value > > > - cppcoreguidelines-implicit-this-capture-by-value > > > - cppcoreguidelines-implicit-by-value-this-capture > > > - cppcoreguidelines-prefer-explicit-this-capture > > > - cppcoreguidelines-avoid-ambiguous-this-capture > > Probably something like this would be good: > > cppcoreguidelines-avoid-implicit-this-capture-by-value > Nice suggestions! I've done a bit of mix of them, let me know if you are > happy with it. To be honest that "default" sounds strange. Simply I check name does not read as an "sentence", more as bunch of words, but I'm fine with this. Comment at: clang-tools-extra/docs/ReleaseNotes.rst:118 Warns when lambda specify a capture default and capture ``this``. maybe "Warns when a lambda captures `this` using the default by-value capture." and align this with check doxygen comment and documentation, because you changed those two but not here. Comment at: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-value-capture-default-this.rst:11 specifying the capture default ``[=]`` will still capture data members by reference. Note: I'm missing here explanation why. (yes I know that this may not be related) Maybe: "By-value capture-defaults in member functions can be misleading about whether data members are captured by value or reference. This occurs because specifying the capture default [=] actually captures the this pointer by value, not the data members themselves. As a result, data members are still indirectly accessed via the captured this pointer, which essentially means they are being accessed by reference. Therefore, even when using [=], data members are effectively captured by reference, which might not align with the user's expectations." Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp marked an inline comment as done. carlosgalvezp added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp:55 +AvoidByValueCaptureDefaultWhenCapturingThisCheck>( + "cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this"); CheckFactories.registerCheck( PiotrZSL wrote: > PiotrZSL wrote: > > this name is hard to understand > > > > I asked ChatGPT about it, and here are some other proposals: > > > > - cppcoreguidelines-avoid-by-value-default-this-capture > > - cppcoreguidelines-avoid-this-capture-by-value-default > > - cppcoreguidelines-explicit-this-capture-by-value > > - cppcoreguidelines-implicit-this-capture-by-value > > - cppcoreguidelines-implicit-by-value-this-capture > > - cppcoreguidelines-prefer-explicit-this-capture > > - cppcoreguidelines-avoid-ambiguous-this-capture > Probably something like this would be good: > cppcoreguidelines-avoid-implicit-this-capture-by-value Nice suggestions! I've done a bit of mix of them, let me know if you are happy with it. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp updated this revision to Diff 513705. carlosgalvezp added a comment. Shorten check name Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 Files: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidValueCaptureDefaultThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidValueCaptureDefaultThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-capture-default-when-capturing-this.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-value-capture-default-this.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-value-capture-default-this.cpp Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-value-capture-default-this.cpp === --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-value-capture-default-this.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-value-capture-default-this.cpp @@ -1,7 +1,4 @@ -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -check-suffixes=,DEFAULT -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-avoid-capture-default-when-capturing-this.IgnoreCaptureDefaultByReference, value: true}]}" +// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-value-capture-default-this %t struct Obj { void lambdas_that_warn_default_capture_copy() { @@ -9,73 +6,60 @@ int local2{}; auto explicit_this_capture = [=, this]() { }; -// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-value-capture-default-this] // CHECK-FIXES: auto explicit_this_capture = [this]() { }; auto explicit_this_capture_locals1 = [=, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-value-capture-default-this] // CHECK-FIXES: auto explicit_this_capture_locals1 = [local, this]() { return (local+x) > 10; }; auto explicit_this_capture_locals2 = [=, this]() { return (local+local2) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-value-capture-default-this] // CHECK-FIXES: auto explicit_this_capture_locals2 = [local, local2, this]() { return (local+local2) > 10; }; auto explicit_this_capture_local_ref = [=, this, &local]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-value-capture-default-this] // CHECK-FIXES: auto explicit_this_capture_local_ref = [this, &local]() { return (local+x) > 10; }; auto explicit_this_capture_local_ref2 = [=, &local, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-value-capture-default-this] // CHECK-FIXES: auto explicit_this_capture_local_ref2 = [&local, this]() { return (local+x) > 10; }; auto explicit_this_capture_
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
PiotrZSL added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp:55 +AvoidByValueCaptureDefaultWhenCapturingThisCheck>( + "cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this"); CheckFactories.registerCheck( PiotrZSL wrote: > this name is hard to understand > > I asked ChatGPT about it, and here are some other proposals: > > - cppcoreguidelines-avoid-by-value-default-this-capture > - cppcoreguidelines-avoid-this-capture-by-value-default > - cppcoreguidelines-explicit-this-capture-by-value > - cppcoreguidelines-implicit-this-capture-by-value > - cppcoreguidelines-implicit-by-value-this-capture > - cppcoreguidelines-prefer-explicit-this-capture > - cppcoreguidelines-avoid-ambiguous-this-capture Probably something like this would be good: cppcoreguidelines-avoid-implicit-this-capture-by-value Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
PiotrZSL added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp:55 +AvoidByValueCaptureDefaultWhenCapturingThisCheck>( + "cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this"); CheckFactories.registerCheck( this name is hard to understand I asked ChatGPT about it, and here are some other proposals: - cppcoreguidelines-avoid-by-value-default-this-capture - cppcoreguidelines-avoid-this-capture-by-value-default - cppcoreguidelines-explicit-this-capture-by-value - cppcoreguidelines-implicit-this-capture-by-value - cppcoreguidelines-implicit-by-value-this-capture - cppcoreguidelines-prefer-explicit-this-capture - cppcoreguidelines-avoid-ambiguous-this-capture Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidByValueCaptureDefaultWhenCapturingThisCheck.h:1 -//===--- AvoidCaptureDefaultWhenCapturingThisCheck.h - clang-tidy*- C++ -*-===// +//===--- AvoidByValueCaptureDefaultWhenCapturingThisCheck.h - clang-tidy*- C++ +//-*-===// Please make it single line by removing all possible `=` and `-`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp updated this revision to Diff 513584. carlosgalvezp added a comment. Remove excessive newlines Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148340/new/ https://reviews.llvm.org/D148340 Files: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidByValueCaptureDefaultWhenCapturingThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidByValueCaptureDefaultWhenCapturingThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-capture-default-when-capturing-this.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.cpp clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.cpp === --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.cpp @@ -1,7 +1,4 @@ -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -check-suffixes=,DEFAULT -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-avoid-capture-default-when-capturing-this.IgnoreCaptureDefaultByReference, value: true}]}" +// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this %t struct Obj { void lambdas_that_warn_default_capture_copy() { @@ -9,73 +6,60 @@ int local2{}; auto explicit_this_capture = [=, this]() { }; -// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this] // CHECK-FIXES: auto explicit_this_capture = [this]() { }; auto explicit_this_capture_locals1 = [=, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this] // CHECK-FIXES: auto explicit_this_capture_locals1 = [local, this]() { return (local+x) > 10; }; auto explicit_this_capture_locals2 = [=, this]() { return (local+local2) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this] // CHECK-FIXES: auto explicit_this_capture_locals2 = [local, local2, this]() { return (local+local2) > 10; }; auto explicit_this_capture_local_ref = [=, this, &local]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this] // CHECK-FIXES: auto explicit_this_capture_local_ref = [this, &local]() { return (local+x) > 10; }; auto explicit_this_capture_local_ref2 = [=, &local, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a b
[PATCH] D148340: [clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default
carlosgalvezp created this revision. Herald added subscribers: PiotrZSL, shchenz, kbarton, xazax.hun, nemanjai. Herald added a reviewer: njames93. Herald added a project: All. carlosgalvezp requested review of this revision. Herald added a project: clang-tools-extra. Herald added a subscriber: cfe-commits. Since Cpp Core Guidelines have accepted the change in the rules: https://github.com/isocpp/CppCoreGuidelines/commit/3c90d590e138c3a1e4eb59234e410e00545326de Also rename the check accordingly. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D148340 Files: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidByValueCaptureDefaultWhenCapturingThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidByValueCaptureDefaultWhenCapturingThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-capture-default-when-capturing-this.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.cpp clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.cpp === --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-by-value-capture-default-when-capturing-this.cpp @@ -1,7 +1,4 @@ -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -check-suffixes=,DEFAULT -// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t \ -// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-avoid-capture-default-when-capturing-this.IgnoreCaptureDefaultByReference, value: true}]}" +// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this %t struct Obj { void lambdas_that_warn_default_capture_copy() { @@ -9,73 +6,63 @@ int local2{}; auto explicit_this_capture = [=, this]() { }; -// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this] // CHECK-FIXES: auto explicit_this_capture = [this]() { }; auto explicit_this_capture_locals1 = [=, this]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this] // CHECK-FIXES: auto explicit_this_capture_locals1 = [local, this]() { return (local+x) > 10; }; auto explicit_this_capture_locals2 = [=, this]() { return (local+local2) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this] // CHECK-FIXES: auto explicit_this_capture_locals2 = [local, local2, this]() { return (local+local2) > 10; }; auto explicit_this_capture_local_ref = [=, this, &local]() { return (local+x) > 10; }; -// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this] +// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a by-value capture default [cppcoreguidelines-avoid-by-value-capture-default-when-capturing-this] // CHECK-FIXES: auto explicit_this_capture_local_ref = [this, &local]() { return (local+x) > 10; }; auto explicit_this_capture_local_ref2 =