From f59b1a92119b4fa04c1f981bde9a97546c46f797 Mon Sep 17 00:00:00 2001 From: Edwin Vane Date: Tue, 13 Aug 2013 16:26:44 +0000 Subject: Fixing a conflict detection bug in tooling::deduplicate If a Replacment is contained within the conflict range being built, the conflict range would be erroneously shortened. Now fixed. Tests updated to catch this case. llvm-svn: 188287 --- clang/lib/Tooling/Refactoring.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'clang/lib/Tooling') diff --git a/clang/lib/Tooling/Refactoring.cpp b/clang/lib/Tooling/Refactoring.cpp index 8599f975120..52daaebfd21 100644 --- a/clang/lib/Tooling/Refactoring.cpp +++ b/clang/lib/Tooling/Refactoring.cpp @@ -206,8 +206,9 @@ void deduplicate(std::vector &Replaces, if (ConflictRange.overlapsWith(Current)) { // Extend conflicted range ConflictRange = Range(ConflictRange.getOffset(), - Current.getOffset() + Current.getLength() - - ConflictRange.getOffset()); + std::max(ConflictRange.getLength(), + Current.getOffset() + Current.getLength() - + ConflictRange.getOffset())); ++ConflictLength; } else { if (ConflictLength > 1) -- cgit v1.2.3