1480093f4SDimitry Andric //===- Mutations.h - mutate syntax trees --------------------*- C++ ---*-=====// 2480093f4SDimitry Andric // 3480093f4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4480093f4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5480093f4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6480093f4SDimitry Andric // 7480093f4SDimitry Andric //===----------------------------------------------------------------------===// 8480093f4SDimitry Andric // Defines high-level APIs for transforming syntax trees and producing the 9480093f4SDimitry Andric // corresponding textual replacements. 10480093f4SDimitry Andric //===----------------------------------------------------------------------===// 11480093f4SDimitry Andric #ifndef LLVM_CLANG_TOOLING_SYNTAX_MUTATIONS_H 12480093f4SDimitry Andric #define LLVM_CLANG_TOOLING_SYNTAX_MUTATIONS_H 13480093f4SDimitry Andric 14480093f4SDimitry Andric #include "clang/Tooling/Core/Replacement.h" 15480093f4SDimitry Andric #include "clang/Tooling/Syntax/Nodes.h" 16*fcaf7f86SDimitry Andric #include "clang/Tooling/Syntax/TokenBufferTokenManager.h" 17480093f4SDimitry Andric #include "clang/Tooling/Syntax/Tree.h" 18480093f4SDimitry Andric 19480093f4SDimitry Andric namespace clang { 20480093f4SDimitry Andric namespace syntax { 21480093f4SDimitry Andric 22480093f4SDimitry Andric /// Computes textual replacements required to mimic the tree modifications made 23480093f4SDimitry Andric /// to the syntax tree. 24*fcaf7f86SDimitry Andric tooling::Replacements computeReplacements(const TokenBufferTokenManager &TBTM, 25480093f4SDimitry Andric const syntax::TranslationUnit &TU); 26480093f4SDimitry Andric 27480093f4SDimitry Andric /// Removes a statement or replaces it with an empty statement where one is 28480093f4SDimitry Andric /// required syntactically. E.g., in the following example: 29480093f4SDimitry Andric /// if (cond) { foo(); } else bar(); 30480093f4SDimitry Andric /// One can remove `foo();` completely and to remove `bar();` we would need to 31480093f4SDimitry Andric /// replace it with an empty statement. 32480093f4SDimitry Andric /// EXPECTS: S->canModify() == true 33*fcaf7f86SDimitry Andric void removeStatement(syntax::Arena &A, TokenBufferTokenManager &TBTM, 34*fcaf7f86SDimitry Andric syntax::Statement *S); 35480093f4SDimitry Andric 36480093f4SDimitry Andric } // namespace syntax 37480093f4SDimitry Andric } // namespace clang 38480093f4SDimitry Andric 39480093f4SDimitry Andric #endif 40