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
17 : public ExpectedLocationVisitor
<LambdaTemplateParametersVisitor
> {
19 bool shouldVisitImplicitCode() const { return false; }
21 bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl
*D
) {
22 EXPECT_FALSE(D
->isImplicit());
23 Match(D
->getName(), D
->getBeginLoc());
27 bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl
*D
) {
28 EXPECT_FALSE(D
->isImplicit());
29 Match(D
->getName(), D
->getBeginLoc());
33 bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl
*D
) {
34 EXPECT_FALSE(D
->isImplicit());
35 Match(D
->getName(), D
->getBeginLoc());
40 TEST(RecursiveASTVisitor
, VisitsLambdaExplicitTemplateParameters
) {
41 LambdaTemplateParametersVisitor Visitor
;
42 Visitor
.ExpectMatch("T", 2, 15);
43 Visitor
.ExpectMatch("I", 2, 24);
44 Visitor
.ExpectMatch("TT", 2, 31);
45 EXPECT_TRUE(Visitor
.runOver(
47 " auto l = []<class T, int I, template<class> class TT>(auto p) { }; \n"
49 LambdaTemplateParametersVisitor::Lang_CXX2a
));
52 } // end anonymous namespace