blob: b1d6d593e733a96cafbbca9cc5d1a30323aeb2eb [file] [log] [blame]
David Zarzyckid488daa2018-04-19 18:19:02 +00001//===- unittest/Tooling/RecursiveASTVisitorTests/LambdaDefaultCapture.cpp -===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
David Zarzyckid488daa2018-04-19 18:19:02 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "TestVisitor.h"
10
11using namespace clang;
12
13namespace {
14
15// Matches the (optional) capture-default of a lambda-introducer.
16class LambdaDefaultCaptureVisitor
17 : public ExpectedLocationVisitor<LambdaDefaultCaptureVisitor> {
18public:
19 bool VisitLambdaExpr(LambdaExpr *Lambda) {
20 if (Lambda->getCaptureDefault() != LCD_None) {
21 Match("", Lambda->getCaptureDefaultLoc());
22 }
23 return true;
24 }
25};
26
27TEST(RecursiveASTVisitor, HasCaptureDefaultLoc) {
28 LambdaDefaultCaptureVisitor Visitor;
29 Visitor.ExpectMatch("", 1, 20);
30 EXPECT_TRUE(Visitor.runOver("void f() { int a; [=]{a;}; }",
31 LambdaDefaultCaptureVisitor::Lang_CXX11));
32}
33
34} // end anonymous namespace