================ @@ -0,0 +1,99 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "RedundantLambdaParenthesesCheck.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace { + +AST_MATCHER(clang::LambdaExpr, hasNoParameters) { + return Node.getCallOperator()->getNumParams() == 0; +} + +AST_MATCHER(clang::LambdaExpr, hasExplicitOrGenericParameters) { + return Node.hasExplicitParameters() || Node.isGenericLambda(); +} + +AST_MATCHER(clang::LambdaExpr, isGenericLambdaInCxx20OrLater) { + return !Node.isGenericLambda() || + Finder->getASTContext().getLangOpts().CPlusPlus20; +} + +} // namespace + +namespace clang::tidy::readability { + +void RedundantLambdaParenthesesCheck::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher(lambdaExpr(hasExplicitOrGenericParameters(), + hasNoParameters(), + isGenericLambdaInCxx20OrLater()) + .bind("lambda"), + this); +} + +void RedundantLambdaParenthesesCheck::check( ---------------- localspook wrote:
I think a lot of the manual parsing here can be avoided; you can do: ```cpp Lambda->getCallOperator()-getFunctionTypeLoc(); ``` to get a `FunctionTypeLoc`, which provides `getLParenLoc` and `getRParenLoc` functions for you. https://github.com/llvm/llvm-project/pull/190438 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
