[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / clang / unittests / Tooling / RecursiveASTVisitorTests / LambdaTemplateParams.cpp
blobcfac3a3c5ad988480e4d3442adc1a659fcbd9b2b
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "TestVisitor.h"
11 using namespace clang;
13 namespace {
15 // Matches (optional) explicit template parameters.
16 class LambdaTemplateParametersVisitor : public ExpectedLocationVisitor {
17 public:
18 LambdaTemplateParametersVisitor() { ShouldVisitImplicitCode = false; }
20 bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) override {
21 EXPECT_FALSE(D->isImplicit());
22 Match(D->getName(), D->getBeginLoc());
23 return true;
26 bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) override {
27 EXPECT_FALSE(D->isImplicit());
28 Match(D->getName(), D->getBeginLoc());
29 return true;
32 bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) override {
33 EXPECT_FALSE(D->isImplicit());
34 Match(D->getName(), D->getBeginLoc());
35 return true;
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(
45 "void f() { \n"
46 " auto l = []<class T, int I, template<class> class TT>(auto p) { }; \n"
47 "}",
48 LambdaTemplateParametersVisitor::Lang_CXX2a));
51 } // end anonymous namespace