llvm/clang/unittests/AST/ASTPrint.h

//===- unittests/AST/ASTPrint.h ------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// Helpers to simplify testing of printing of AST constructs provided in the/
// form of the source code.
//
//===----------------------------------------------------------------------===//

#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/SmallString.h"
#include "gtest/gtest.h"

namespace clang {

PrintingPolicyAdjuster;

NodePrinter;

NodeFilter;

template <typename NodeType>
class PrintMatch : public ast_matchers::MatchFinder::MatchCallback {};

template <typename NodeType> bool NoNodeFilter(const NodeType *) {}

template <typename NodeType, typename Matcher>
::testing::AssertionResult
PrintedNodeMatches(StringRef Code, const std::vector<std::string> &Args,
                   const Matcher &NodeMatch, StringRef ExpectedPrinted,
                   StringRef FileName, NodePrinter<NodeType> Printer,
                   PrintingPolicyAdjuster PolicyAdjuster = nullptr,
                   bool AllowError = false,
                   // Would like to use a lambda for the default value, but that
                   // trips gcc 7 up.
                   NodeFilter<NodeType> Filter = &NoNodeFilter<NodeType>) {}

} // namespace clang