[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / clang / unittests / Tooling / RecursiveASTVisitorTests / TemplateArgumentLocTraverser.cpp
blobe5e743ab8d76daddda941a6c376a69e34472774a
1 //===- TemplateArgumentLocTraverser.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 class TemplateArgumentLocTraverser : public ExpectedLocationVisitor {
16 public:
17 bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc) override {
18 std::string ArgStr;
19 llvm::raw_string_ostream Stream(ArgStr);
20 const TemplateArgument &Arg = ArgLoc.getArgument();
22 Arg.print(Context->getPrintingPolicy(), Stream, /*IncludeType*/ true);
23 Match(ArgStr, ArgLoc.getLocation());
24 return ExpectedLocationVisitor::TraverseTemplateArgumentLoc(ArgLoc);
28 TEST(RecursiveASTVisitor, VisitsClassTemplateTemplateParmDefaultArgument) {
29 TemplateArgumentLocTraverser Visitor;
30 Visitor.ExpectMatch("X", 2, 40);
31 EXPECT_TRUE(Visitor.runOver(
32 "template<typename T> class X;\n"
33 "template<template <typename> class T = X> class Y;\n"
34 "template<template <typename> class T> class Y {};\n"));
37 } // end anonymous namespace