summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-08-13 17:38:19 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-08-13 17:38:19 +0000
commit349e1c18eb37d67acfdac93344426c04f2b03341 (patch)
tree570e49dca51a5e42189bb5e147402febf065edda /clang/lib
parent72f7821cc6155c285d37e167a6462d642ff224dc (diff)
downloadbcm5719-llvm-349e1c18eb37d67acfdac93344426c04f2b03341.tar.gz
bcm5719-llvm-349e1c18eb37d67acfdac93344426c04f2b03341.zip
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 llvm-svn: 188295
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Tooling/Refactoring.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Tooling/Refactoring.cpp b/clang/lib/Tooling/Refactoring.cpp
index 52daaebfd21..bc94a2b2c1f 100644
--- a/clang/lib/Tooling/Refactoring.cpp
+++ b/clang/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(
OpenPOWER on IntegriCloud