Index: include/clang/Tooling/Refactoring/AtomicChange.h =================================================================== --- include/clang/Tooling/Refactoring/AtomicChange.h +++ include/clang/Tooling/Refactoring/AtomicChange.h @@ -70,6 +70,12 @@ /// \brief Returns the error message or an empty string if it does not exist. const std::string &getError() const { return Error; } + /// \brief Adds a replacement that replaces the given Range with + /// ReplacementText. + /// \returns An llvm::Error carrying ReplacementError on error. + llvm::Error replace(const SourceManager &SM, const CharSourceRange &Range, + llvm::StringRef ReplacementText); + /// \brief Adds a replacement that replaces range [Loc, Loc+Length) with /// \p Text. /// \returns An llvm::Error carrying ReplacementError on error. Index: lib/Tooling/Refactoring/AtomicChange.cpp =================================================================== --- lib/Tooling/Refactoring/AtomicChange.cpp +++ lib/Tooling/Refactoring/AtomicChange.cpp @@ -132,6 +132,12 @@ return E; } +llvm::Error AtomicChange::replace(const SourceManager &SM, + const CharSourceRange &Range, + llvm::StringRef ReplacementText) { + return Replaces.add(Replacement(SM, Range, ReplacementText)); +} + llvm::Error AtomicChange::replace(const SourceManager &SM, SourceLocation Loc, unsigned Length, llvm::StringRef Text) { return Replaces.add(Replacement(SM, Loc, Length, Text));