[PATCH] D31492: Add `addReplacement` interface in AtomicChange.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 30 02:44:00 PDT 2017


hokein updated this revision to Diff 93456.
hokein added a comment.

Get rid of Replacement, and implement "replace" interface with range.


https://reviews.llvm.org/D31492

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/Refactoring/AtomicChange.cpp


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 Replacements.add(Replacement(SM, Range, ReplacementText));
+}
+
 llvm::Error AtomicChange::insert(const SourceManager &SM, SourceLocation Loc,
                                  llvm::StringRef Text, bool InsertAfter) {
   if (Text.empty())
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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31492.93456.patch
Type: text/x-patch
Size: 1534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170330/0598024d/attachment.bin>


More information about the cfe-commits mailing list