
This pr refactors most tests that use RAV to use DRAV instead; this also has the nice effect of testing both the RAV and DRAV implementations at the same time w/o having to duplicate all of our AST visitor tests. Some tests rely on features that DRAV doesn’t support (mainly post-order traversal), so those haven’t been migrated. At the same time, `TestVisitor` is now a DRAV, so I’ve had to introduce a new `CTRPTestVisitor` for any tests that need to use RAV directly.
38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
//===- TemplateArgumentLocTraverser.cpp -----------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "TestVisitor.h"
|
|
|
|
using namespace clang;
|
|
|
|
namespace {
|
|
|
|
class TemplateArgumentLocTraverser : public ExpectedLocationVisitor {
|
|
public:
|
|
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc) override {
|
|
std::string ArgStr;
|
|
llvm::raw_string_ostream Stream(ArgStr);
|
|
const TemplateArgument &Arg = ArgLoc.getArgument();
|
|
|
|
Arg.print(Context->getPrintingPolicy(), Stream, /*IncludeType*/ true);
|
|
Match(ArgStr, ArgLoc.getLocation());
|
|
return ExpectedLocationVisitor::TraverseTemplateArgumentLoc(ArgLoc);
|
|
}
|
|
};
|
|
|
|
TEST(RecursiveASTVisitor, VisitsClassTemplateTemplateParmDefaultArgument) {
|
|
TemplateArgumentLocTraverser Visitor;
|
|
Visitor.ExpectMatch("X", 2, 40);
|
|
EXPECT_TRUE(Visitor.runOver(
|
|
"template<typename T> class X;\n"
|
|
"template<template <typename> class T = X> class Y;\n"
|
|
"template<template <typename> class T> class Y {};\n"));
|
|
}
|
|
|
|
} // end anonymous namespace
|