================
@@ -5125,6 +5125,20 @@ AST_MATCHER_P(LambdaCapture, capturesVar, 
internal::Matcher<ValueDecl>,
 ///   matches `[this]() { return cc; }`.
 AST_MATCHER(LambdaCapture, capturesThis) { return Node.capturesThis(); }
 
+/// Matches lambda expressions that have default capture modes.
+///
+/// Given
+/// \code
+///   auto l1 = [=]() {};  // matches
+///   auto l2 = [&]() {};  // matches
+///   auto l3 = []() {};   // does not match
+/// \endcode
+/// lambdaExpr(hasDefaultCapture())
+///   matches l1 and l2, but not l3.
+AST_MATCHER(LambdaExpr, hasDefaultCapture) {
+  return Node.getCaptureDefault() != LCD_None;
+}
----------------
vbvictor wrote:

Please add unit tests in 
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

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

Reply via email to