#include "clang/Tooling/Transformer/RewriteRule.h"
#include "clang/AST/ASTTypeTraits.h"
#include "clang/AST/Stmt.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Tooling/Transformer/SourceCode.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include <map>
#include <string>
#include <utility>
#include <vector>
usingnamespaceclang;
usingnamespacetransformer;
MatchFinder;
DynTypedMatcher;
MatchResult;
const char transformer::RootID[] = …;
static Expected<SmallVector<transformer::Edit, 1>>
translateEdits(const MatchResult &Result, ArrayRef<ASTEdit> ASTEdits) { … }
EditGenerator transformer::editList(SmallVector<ASTEdit, 1> Edits) { … }
EditGenerator transformer::edit(ASTEdit Edit) { … }
EditGenerator transformer::noopEdit(RangeSelector Anchor) { … }
EditGenerator
transformer::flattenVector(SmallVector<EditGenerator, 2> Generators) { … }
ASTEdit transformer::changeTo(RangeSelector Target, TextGenerator Replacement) { … }
ASTEdit transformer::note(RangeSelector Anchor, TextGenerator Note) { … }
namespace {
class SimpleTextGenerator : public MatchComputation<std::string> { … };
}
static TextGenerator makeText(std::string S) { … }
ASTEdit transformer::remove(RangeSelector S) { … }
static std::string formatHeaderPath(StringRef Header, IncludeFormat Format) { … }
ASTEdit transformer::addInclude(RangeSelector Target, StringRef Header,
IncludeFormat Format) { … }
EditGenerator
transformer::detail::makeEditGenerator(llvm::SmallVector<ASTEdit, 1> Edits) { … }
EditGenerator transformer::detail::makeEditGenerator(ASTEdit Edit) { … }
RewriteRule transformer::detail::makeRule(DynTypedMatcher M,
EditGenerator Edits) { … }
RewriteRule transformer::makeRule(ast_matchers::internal::DynTypedMatcher M,
std::initializer_list<ASTEdit> Edits) { … }
namespace {
template <typename T>
class BindingsMatcher : public ast_matchers::internal::MatcherInterface<T> { … };
template <typename T>
class DynamicForEachDescendantMatcher
: public ast_matchers::internal::MatcherInterface<T> { … };
template <typename T>
ast_matchers::internal::Matcher<T>
forEachDescendantDynamically(ast_matchers::BoundNodes Nodes,
DynTypedMatcher M) { … }
class ApplyRuleCallback : public MatchFinder::MatchCallback { … };
}
template <typename T>
llvm::Expected<SmallVector<clang::transformer::Edit, 1>>
rewriteDescendantsImpl(const T &Node, RewriteRule Rule,
const MatchResult &Result) { … }
llvm::Expected<SmallVector<clang::transformer::Edit, 1>>
transformer::detail::rewriteDescendants(const Decl &Node, RewriteRule Rule,
const MatchResult &Result) { … }
llvm::Expected<SmallVector<clang::transformer::Edit, 1>>
transformer::detail::rewriteDescendants(const Stmt &Node, RewriteRule Rule,
const MatchResult &Result) { … }
llvm::Expected<SmallVector<clang::transformer::Edit, 1>>
transformer::detail::rewriteDescendants(const TypeLoc &Node, RewriteRule Rule,
const MatchResult &Result) { … }
llvm::Expected<SmallVector<clang::transformer::Edit, 1>>
transformer::detail::rewriteDescendants(const DynTypedNode &DNode,
RewriteRule Rule,
const MatchResult &Result) { … }
EditGenerator transformer::rewriteDescendants(std::string NodeId,
RewriteRule Rule) { … }
void transformer::addInclude(RewriteRuleBase &Rule, StringRef Header,
IncludeFormat Format) { … }
#ifndef NDEBUG
static bool hasValidKind(const DynTypedMatcher &M) {
return !M.canConvertTo<QualType>();
}
#endif
static std::vector<DynTypedMatcher> taggedMatchers(
StringRef TagBase,
const SmallVectorImpl<std::pair<size_t, RewriteRule::Case>> &Cases,
TraversalKind DefaultTraversalKind) { … }
template <>
RewriteRuleWith<void>
transformer::applyFirst(ArrayRef<RewriteRuleWith<void>> Rules) { … }
std::vector<DynTypedMatcher>
transformer::detail::buildMatchers(const RewriteRuleBase &Rule) { … }
DynTypedMatcher transformer::detail::buildMatcher(const RewriteRuleBase &Rule) { … }
SourceLocation transformer::detail::getRuleMatchLoc(const MatchResult &Result) { … }
size_t transformer::detail::findSelectedCase(const MatchResult &Result,
const RewriteRuleBase &Rule) { … }