blob: c3f8e4f41943e4f9bb97df631120fb66b83880f2 [file] [log] [blame]
David Zarzyckid488daa2018-04-19 18:19:02 +00001//===- unittest/Tooling/RecursiveASTVisitorTests/LambdaDefaultCapture.cpp -===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "TestVisitor.h"
11
12using namespace clang;
13
14namespace {
15
16// Matches the (optional) capture-default of a lambda-introducer.
17class LambdaDefaultCaptureVisitor
18 : public ExpectedLocationVisitor<LambdaDefaultCaptureVisitor> {
19public:
20 bool VisitLambdaExpr(LambdaExpr *Lambda) {
21 if (Lambda->getCaptureDefault() != LCD_None) {
22 Match("", Lambda->getCaptureDefaultLoc());
23 }
24 return true;
25 }
26};
27
28TEST(RecursiveASTVisitor, HasCaptureDefaultLoc) {
29 LambdaDefaultCaptureVisitor Visitor;
30 Visitor.ExpectMatch("", 1, 20);
31 EXPECT_TRUE(Visitor.runOver("void f() { int a; [=]{a;}; }",
32 LambdaDefaultCaptureVisitor::Lang_CXX11));
33}
34
35} // end anonymous namespace