1 //===- TemplateArgumentLocTraverser.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 class TemplateArgumentLocTraverser
: public ExpectedLocationVisitor
{
17 bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc
&ArgLoc
) override
{
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