Trying to buildbot failures caused by r282577.
authorEric Liu <ioeric@google.com>
Wed, 28 Sep 2016 12:49:14 +0000 (12:49 +0000)
committerEric Liu <ioeric@google.com>
Wed, 28 Sep 2016 12:49:14 +0000 (12:49 +0000)
llvm-svn: 282583

clang/lib/Tooling/Core/Replacement.cpp

index 9184883..7a5fb85 100644 (file)
@@ -287,8 +287,13 @@ llvm::Error Replacements::add(const Replacement &R) {
     // with them and replace them with the merged replacements.
     auto MergeBegin = I;
     auto MergeEnd = std::next(I);
-    while (I-- != Replaces.begin() && Overlap(R, *I))
+    while (I != Replaces.begin()) {
+      --I;
+      // If `I` doesn't overlap with `R`, don't merge it.
+      if (!Overlap(R, *I))
+        break;
       MergeBegin = I;
+    }
     Replacements OverlapReplaces(MergeBegin, MergeEnd);
     llvm::Expected<Replacements> Merged =
         OverlapReplaces.mergeIfOrderIndependent(R);