Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / unittests / Tooling / RecursiveASTVisitorTests / TemplateArgumentLocTraverser.cpp
blob5eee19f0730e42ca9bfa4294afed7c8781a3ac65
1 //===- unittest/Tooling/RecursiveASTVisitorTests/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
16 : public ExpectedLocationVisitor<TemplateArgumentLocTraverser> {
17 public:
18 bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc) {
19 std::string ArgStr;
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