| 1 |
//===--- TestVisitor.h ------------------------------------------*- C++ -*-===// |
| 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 |
//===----------------------------------------------------------------------===// |
| 8 |
/// |
| 9 |
/// \file |
| 10 |
/// \brief Defines a CRTP-based RecursiveASTVisitor helper for tests. |
| 11 |
/// |
| 12 |
//===----------------------------------------------------------------------===// |
| 13 |
|
| 14 |
#ifndef LLVM_CLANG_UNITTESTS_TOOLING_CRTPTESTVISITOR_H |
| 15 |
#define LLVM_CLANG_UNITTESTS_TOOLING_CRTPTESTVISITOR_H |
| 16 |
|
| 17 |
#include "TestVisitor.h" |
| 18 |
#include "clang/AST/RecursiveASTVisitor.h" |
| 19 |
|
| 20 |
// CRTP versions of the visitors in TestVisitor.h. |
| 21 |
namespace clang { |
| 22 |
template <typename T> |
| 23 |
class CRTPTestVisitor : public RecursiveASTVisitor<T>, |
| 24 |
public detail::TestVisitorHelper { |
| 25 |
public: |
| 26 |
bool shouldVisitTemplateInstantiations() const { return true; } |
| 27 |
bool shouldVisitImplicitCode() const { return true; } |
| 28 |
|
| 29 |
void InvokeTraverseDecl(TranslationUnitDecl *D) override { |
| 30 |
RecursiveASTVisitor<T>::TraverseDecl(D); |
| 31 |
} |
| 32 |
}; |
| 33 |
|
| 34 |
template <typename T> |
| 35 |
class CRTPExpectedLocationVisitor |
| 36 |
: public CRTPTestVisitor<T>, |
| 37 |
public detail::ExpectedLocationVisitorHelper { |
| 38 |
ASTContext *getASTContext() override { return this->Context; } |
| 39 |
}; |
| 40 |
} // namespace clang |
| 41 |
|
| 42 |
#endif // LLVM_CLANG_UNITTESTS_TOOLING_CRTPTESTVISITOR_H |