brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 4a9175e Raw
34 lines · cpp
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-exception6//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 : public ExpectedLocationVisitor {17public:18  bool VisitLambdaExpr(LambdaExpr *Lambda) override {19    if (Lambda->getCaptureDefault() != LCD_None) {20      Match("", Lambda->getCaptureDefaultLoc());21    }22    return true;23  }24};25 26TEST(RecursiveASTVisitor, HasCaptureDefaultLoc) {27  LambdaDefaultCaptureVisitor Visitor;28  Visitor.ExpectMatch("", 1, 20);29  EXPECT_TRUE(Visitor.runOver("void f() { int a; [=]{a;}; }",30                              LambdaDefaultCaptureVisitor::Lang_CXX11));31}32 33} // end anonymous namespace34