13#include "llvm/Support/Error.h"
23 ProcessTokensFn Callback) {
26 ProcessTokensFn Callback)
27 : STM(STM), SpanBegin(nullptr), SpanEnd(nullptr), SpanIsOriginal(
false),
39 if (
auto *
T = dyn_cast<syntax::Tree>(N)) {
40 for (
const auto *
C =
T->getFirstChild();
C !=
nullptr;
41 C =
C->getNextSibling())
46 auto *L = cast<syntax::Leaf>(N);
47 if (SpanEnd == STM.
getToken(L->getTokenKey()) &&
48 SpanIsOriginal == L->isOriginal()) {
57 SpanBegin = STM.
getToken(L->getTokenKey());
58 SpanEnd = SpanBegin + 1;
59 SpanIsOriginal = L->isOriginal();
66 ProcessTokensFn Callback;
69 return Enumerator(STM, Callback).run(Root);
78 assert(Buffer.expandedTokens().begin() <= Expanded.begin());
79 assert(Expanded.end() < Buffer.expandedTokens().end());
84 SM,
SM.getExpansionLoc(Expanded.begin()->location()), 0);
86 auto Spelled = Buffer.spelledForExpanded(Expanded);
87 assert(Spelled &&
"could not find spelled tokens for expanded");
94 const syntax::TranslationUnit &TU) {
100 std::string Replacement;
102 if (ReplacedRange.empty() && Replacement.empty())
105 SM, rangeOfExpanded(TBTM, ReplacedRange).toCharRange(
SM),
109 const syntax::Token *NextOriginal = Buffer.expandedTokens().begin();
117 assert(NextOriginal <= Tokens.begin());
119 if (NextOriginal != Tokens.begin()) {
126 NextOriginal = Tokens.end();
131 llvm::ArrayRef(NextOriginal, Buffer.expandedTokens().drop_back().end()));
static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, unsigned AbsKind, QualType ArgType)
A TokenBuffer-powered token manager.
const syntax::Token * getToken(Key I) const
const TokenBuffer & tokenBuffer() const
SourceManager & sourceManager()
A token coming directly from a file or from a macro invocation.
FileRange range(const SourceManager &SM) const
Gets a range of this token.
A node that has children and represents a syntactic language construct.
tooling::Replacements computeReplacements(const TokenBufferTokenManager &TBTM, const syntax::TranslationUnit &TU)
Computes textual replacements required to mimic the tree modifications made to the syntax tree.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
A half-open character range inside a particular file, the start offset is included and the end offset...
llvm::StringRef text(const SourceManager &SM) const
Gets the substring that this FileRange refers to.