1 //===- unittest/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp -===//
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-exception
7 //===----------------------------------------------------------------------===//
9 #include "TestVisitor.h"
11 using namespace clang
;
15 // Matches (optional) explicit template parameters.
16 class LambdaTemplateParametersVisitor
: public ExpectedLocationVisitor
{
18 LambdaTemplateParametersVisitor() { ShouldVisitImplicitCode
= false; }
20 bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl
*D
) override
{
21 EXPECT_FALSE(D
->isImplicit());
22 Match(D
->getName(), D
->getBeginLoc());
26 bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl
*D
) override
{
27 EXPECT_FALSE(D
->isImplicit());
28 Match(D
->getName(), D
->getBeginLoc());
32 bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl
*D
) override
{
33 EXPECT_FALSE(D
->isImplicit());
34 Match(D
->getName(), D
->getBeginLoc());
39 TEST(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(
46 " auto l = []<class T, int I, template<class> class TT>(auto p) { }; \n"
48 LambdaTemplateParametersVisitor::Lang_CXX2a
));
51 } // end anonymous namespace