From 9dd834653b811ad20382e98a87dff824980c9916 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 21 Jun 2015 14:00:56 +0000 Subject: Vendor import of clang trunk r240225: https://llvm.org/svn/llvm-project/cfe/trunk@240225 --- lib/Tooling/Core/Replacement.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/Tooling/Core/Replacement.cpp') diff --git a/lib/Tooling/Core/Replacement.cpp b/lib/Tooling/Core/Replacement.cpp index 32e8e5b..6d37a49 100644 --- a/lib/Tooling/Core/Replacement.cpp +++ b/lib/Tooling/Core/Replacement.cpp @@ -88,8 +88,13 @@ std::string Replacement::toString() const { bool operator<(const Replacement &LHS, const Replacement &RHS) { if (LHS.getOffset() != RHS.getOffset()) return LHS.getOffset() < RHS.getOffset(); + + // Apply longer replacements first, specifically so that deletions are + // executed before insertions. It is (hopefully) never the intention to + // delete parts of newly inserted code. if (LHS.getLength() != RHS.getLength()) - return LHS.getLength() < RHS.getLength(); + return LHS.getLength() > RHS.getLength(); + if (LHS.getFilePath() != RHS.getFilePath()) return LHS.getFilePath() < RHS.getFilePath(); return LHS.getReplacementText() < RHS.getReplacementText(); -- cgit v1.1