================
@@ -21,19 +21,40 @@ AST_MATCHER(LambdaExpr, hasCoroutineBody) {
 }
 
 AST_MATCHER(LambdaExpr, hasCaptures) { return Node.capture_size() != 0U; }
+
+AST_MATCHER(LambdaExpr, hasDeducingThis) {
+  return Node.getCallOperator()->isExplicitObjectMemberFunction();
+}
 } // namespace
 
+AvoidCapturingLambdaCoroutinesCheck::AvoidCapturingLambdaCoroutinesCheck(
+    StringRef Name, ClangTidyContext *Context)
+    : ClangTidyCheck(Name, Context),
+      AllowExplicitObjectParameters(
+          Options.get("AllowExplicitObjectParameters", false)) {}
+
 void AvoidCapturingLambdaCoroutinesCheck::registerMatchers(
     MatchFinder *Finder) {
-  Finder->addMatcher(
-      lambdaExpr(hasCaptures(), hasCoroutineBody()).bind("lambda"), this);
+  auto Matcher = lambdaExpr(hasCaptures(), hasCoroutineBody());
+
+  if (AllowExplicitObjectParameters)
+    Matcher = lambdaExpr(hasCaptures(), hasCoroutineBody(),
+                         unless(hasDeducingThis()));
----------------
vbvictor wrote:

You should be able to write +- in such form, without duplication full matcher:

```suggestion
    
    const ast_matchers::internal::Matcher<LambdaExpr> Nothing = 
unless(anything()); 
    Matcher = lambdaExpr(hasCaptures(), hasCoroutineBody(),
                         AllowExplicitObjectParameters ? 
unless(hasDeducingThis()), Nothing));
```

https://github.com/llvm/llvm-project/pull/182916
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to