brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · cfac3a3 Raw
52 lines · cpp
1//===- unittest/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.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 (optional) explicit template parameters.16class LambdaTemplateParametersVisitor : public ExpectedLocationVisitor {17public:18  LambdaTemplateParametersVisitor() { ShouldVisitImplicitCode = false; }19 20  bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) override {21    EXPECT_FALSE(D->isImplicit());22    Match(D->getName(), D->getBeginLoc());23    return true;24  }25 26  bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) override {27    EXPECT_FALSE(D->isImplicit());28    Match(D->getName(), D->getBeginLoc());29    return true;30  }31 32  bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) override {33    EXPECT_FALSE(D->isImplicit());34    Match(D->getName(), D->getBeginLoc());35    return true;36  }37};38 39TEST(RecursiveASTVisitor, VisitsLambdaExplicitTemplateParameters) {40  LambdaTemplateParametersVisitor Visitor;41  Visitor.ExpectMatch("T",  2, 15);42  Visitor.ExpectMatch("I",  2, 24);43  Visitor.ExpectMatch("TT", 2, 31);44  EXPECT_TRUE(Visitor.runOver(45      "void f() { \n"46      "  auto l = []<class T, int I, template<class> class TT>(auto p) { }; \n"47      "}",48      LambdaTemplateParametersVisitor::Lang_CXX2a));49}50 51} // end anonymous namespace52