Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / unittests / Tooling / RecursiveASTVisitorTests / LambdaDefaultCapture.cpp
blobb1d6d593e733a96cafbbca9cc5d1a30323aeb2eb
1 //===- unittest/Tooling/RecursiveASTVisitorTests/LambdaDefaultCapture.cpp -===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "TestVisitor.h"
11 using namespace clang;
13 namespace {
15 // Matches the (optional) capture-default of a lambda-introducer.
16 class LambdaDefaultCaptureVisitor
17 : public ExpectedLocationVisitor<LambdaDefaultCaptureVisitor> {
18 public:
19 bool VisitLambdaExpr(LambdaExpr *Lambda) {
20 if (Lambda->getCaptureDefault() != LCD_None) {
21 Match("", Lambda->getCaptureDefaultLoc());
23 return true;
27 TEST(RecursiveASTVisitor, HasCaptureDefaultLoc) {
28 LambdaDefaultCaptureVisitor Visitor;
29 Visitor.ExpectMatch("", 1, 20);
30 EXPECT_TRUE(Visitor.runOver("void f() { int a; [=]{a;}; }",
31 LambdaDefaultCaptureVisitor::Lang_CXX11));
34 } // end anonymous namespace