Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / unittests / Tooling / RecursiveASTVisitorTests / LambdaTemplateParams.cpp
blobc355e3f1083f966fc4da32591d3fbb6956ba98c9
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
17 : public ExpectedLocationVisitor<LambdaTemplateParametersVisitor> {
18 public:
19 bool shouldVisitImplicitCode() const { return false; }
21 bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
22 EXPECT_FALSE(D->isImplicit());
23 Match(D->getName(), D->getBeginLoc());
24 return true;
27 bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
28 EXPECT_FALSE(D->isImplicit());
29 Match(D->getName(), D->getBeginLoc());
30 return true;
33 bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
34 EXPECT_FALSE(D->isImplicit());
35 Match(D->getName(), D->getBeginLoc());
36 return true;
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(
46 "void f() { \n"
47 " auto l = []<class T, int I, template<class> class TT>(auto p) { }; \n"
48 "}",
49 LambdaTemplateParametersVisitor::Lang_CXX2a));
52 } // end anonymous namespace