1 //===- unittest/Tooling/RecursiveASTVisitorTests/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
16 : public ExpectedLocationVisitor
<TemplateArgumentLocTraverser
> {
18 bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc
&ArgLoc
) {
20 llvm::raw_string_ostream
Stream(ArgStr
);
21 const TemplateArgument
&Arg
= ArgLoc
.getArgument();
23 Arg
.print(Context
->getPrintingPolicy(), Stream
, /*IncludeType*/ true);
24 Match(Stream
.str(), ArgLoc
.getLocation());
25 return ExpectedLocationVisitor
<TemplateArgumentLocTraverser
>::
26 TraverseTemplateArgumentLoc(ArgLoc
);
30 TEST(RecursiveASTVisitor
, VisitsClassTemplateTemplateParmDefaultArgument
) {
31 TemplateArgumentLocTraverser Visitor
;
32 Visitor
.ExpectMatch("X", 2, 40);
33 EXPECT_TRUE(Visitor
.runOver(
34 "template<typename T> class X;\n"
35 "template<template <typename> class T = X> class Y;\n"
36 "template<template <typename> class T> class Y {};\n"));
39 } // end anonymous namespace