brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 79dc84b Raw
42 lines · cpp
1//===- unittest/Tooling/RecursiveASTVisitorTests/Class.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// Checks for lambda classes that are not marked as implicitly-generated.16// (There should be none.)17class ClassVisitor : public ExpectedLocationVisitor {18public:19  ClassVisitor() : SawNonImplicitLambdaClass(false) {}20 21  bool VisitCXXRecordDecl(CXXRecordDecl *record) override {22    if (record->isLambda() && !record->isImplicit())23      SawNonImplicitLambdaClass = true;24    return true;25  }26 27  bool sawOnlyImplicitLambdaClasses() const {28    return !SawNonImplicitLambdaClass;29  }30 31private:32  bool SawNonImplicitLambdaClass;33};34 35TEST(RecursiveASTVisitor, LambdaClosureTypesAreImplicit) {36  ClassVisitor Visitor;37  EXPECT_TRUE(Visitor.runOver("auto lambda = []{};", ClassVisitor::Lang_CXX11));38  EXPECT_TRUE(Visitor.sawOnlyImplicitLambdaClasses());39}40 41} // end anonymous namespace42