diff options
author | Edwin Vane <edwin.vane@intel.com> | 2013-08-13 17:38:19 +0000 |
---|---|---|
committer | Edwin Vane <edwin.vane@intel.com> | 2013-08-13 17:38:19 +0000 |
commit | b58cfd93c49727c1d471ce71901502df824556c7 (patch) | |
tree | 51ff50f7ed12847d7a0fdbf91219d28eb31b9429 /lib/Tooling/Refactoring.cpp | |
parent | 95f0766c1942c8cdc9f913a083ad2bfc4c0c27c9 (diff) |
Adding a vector version of tooling::applyAllReplacements
One day soon, tooling::Replacements will be changed from being implemented as
an std::set to being implemented as an std::vector. Until then, some new code
using vectors of Replacements would enjoy having a version of
applyAllReplacements that takes a vector.
Differential Revision: http://llvm-reviews.chandlerc.com/D1380
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188295 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling/Refactoring.cpp')
-rw-r--r-- | lib/Tooling/Refactoring.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Tooling/Refactoring.cpp b/lib/Tooling/Refactoring.cpp index 52daaebfd2..bc94a2b2c1 100644 --- a/lib/Tooling/Refactoring.cpp +++ b/lib/Tooling/Refactoring.cpp @@ -143,6 +143,23 @@ bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite) { return Result; } +// FIXME: Remove this function when Replacements is implemented as std::vector +// instead of std::set. +bool applyAllReplacements(const std::vector<Replacement> &Replaces, + Rewriter &Rewrite) { + bool Result = true; + for (std::vector<Replacement>::const_iterator I = Replaces.begin(), + E = Replaces.end(); + I != E; ++I) { + if (I->isApplicable()) { + Result = I->apply(Rewrite) && Result; + } else { + Result = false; + } + } + return Result; +} + std::string applyAllReplacements(StringRef Code, const Replacements &Replaces) { FileManager Files((FileSystemOptions())); DiagnosticsEngine Diagnostics( |