[clang-tools-extra] [clang-tidy] Add readability-redundant-lambda-parentheses check (PR #190438)

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 8 15:02:15 PDT 2026


================
@@ -86,6 +86,22 @@ int main() {
   auto s = []() noexcept [[]] {};
   // CHECK-MESSAGES-CXX23: :[[@LINE-1]]:14: warning: redundant empty parameter list in lambda expression [readability-redundant-lambda-parentheses]
   // CHECK-FIXES-CXX23:   auto s = [] noexcept {{\[\[}}{{\]\]}} {};
+
+  auto t = []( /* comment */ ) { return 42; };
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: redundant empty parameter list in lambda expression [readability-redundant-lambda-parentheses]
+  // CHECK-FIXES:   auto t = [] { return 42; };
+
+  auto u = []() /* comment */ { return 42; };
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: redundant empty parameter list in lambda expression [readability-redundant-lambda-parentheses]
+  // CHECK-FIXES:   auto u = [] /* comment */ { return 42; };
+
+  auto w = [](/* comment */) { return 42; };
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: redundant empty parameter list in lambda expression [readability-redundant-lambda-parentheses]
+  // CHECK-FIXES:   auto w = [] { return 42; };
----------------
localspook wrote:

Hmm, that may cause a broken fix-it on code like `[] (void) {}`
I didn't really think of this scenario before, can we add a test for it?

https://github.com/llvm/llvm-project/pull/190438


More information about the cfe-commits mailing list