//===- TokenRewriter.cpp - Token-based code rewriting interface -----------===// // // 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 // //===----------------------------------------------------------------------===// // // This file implements the TokenRewriter class, which is used for code // transformations. // //===----------------------------------------------------------------------===// #include "clang/Rewrite/Core/TokenRewriter.h" #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" #include "clang/Lex/ScratchBuffer.h" #include "clang/Lex/Token.h" #include <cassert> #include <cstring> #include <map> #include <utility> usingnamespaceclang; TokenRewriter::TokenRewriter(FileID FID, SourceManager &SM, const LangOptions &LangOpts) { … } TokenRewriter::~TokenRewriter() = default; /// RemapIterator - Convert from token_iterator (a const iterator) to /// TokenRefTy (a non-const iterator). TokenRewriter::TokenRefTy TokenRewriter::RemapIterator(token_iterator I) { … } /// AddToken - Add the specified token into the Rewriter before the other /// position. TokenRewriter::TokenRefTy TokenRewriter::AddToken(const Token &T, TokenRefTy Where) { … } TokenRewriter::token_iterator TokenRewriter::AddTokenBefore(token_iterator I, const char *Val) { … }