summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Tooling/RefactoringTest.cpp
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-08-13 16:26:44 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-08-13 16:26:44 +0000
commitf59b1a92119b4fa04c1f981bde9a97546c46f797 (patch)
tree95ab4c15bd1c5eaf7796254f402bf3f7da330853 /clang/unittests/Tooling/RefactoringTest.cpp
parentbd9d059e6c2ee9ef287b3230e8cced45815f8316 (diff)
downloadbcm5719-llvm-f59b1a92119b4fa04c1f981bde9a97546c46f797.tar.gz
bcm5719-llvm-f59b1a92119b4fa04c1f981bde9a97546c46f797.zip
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
Diffstat (limited to 'clang/unittests/Tooling/RefactoringTest.cpp')
-rw-r--r--clang/unittests/Tooling/RefactoringTest.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/unittests/Tooling/RefactoringTest.cpp b/clang/unittests/Tooling/RefactoringTest.cpp
index 3030162858a..d9f023d9653 100644
--- a/clang/unittests/Tooling/RefactoringTest.cpp
+++ b/clang/unittests/Tooling/RefactoringTest.cpp
@@ -400,20 +400,25 @@ TEST(DeduplicateTest, detectsConflicts) {
// returned conflict info refers to.
Input.push_back(Replacement("fileA", 0, 5, " foo ")); // 0
Input.push_back(Replacement("fileA", 5, 5, " bar ")); // 1
+ Input.push_back(Replacement("fileA", 6, 0, " bar ")); // 3
Input.push_back(Replacement("fileA", 5, 5, " moo ")); // 2
- Input.push_back(Replacement("fileA", 15, 5, " golf ")); // 4
- Input.push_back(Replacement("fileA", 16, 5, " bag ")); // 5
- Input.push_back(Replacement("fileA", 10, 3, " club ")); // 6
+ Input.push_back(Replacement("fileA", 7, 2, " bar ")); // 4
+ Input.push_back(Replacement("fileA", 15, 5, " golf ")); // 5
+ Input.push_back(Replacement("fileA", 16, 5, " bag ")); // 6
+ Input.push_back(Replacement("fileA", 10, 3, " club ")); // 7
+
+ // #3 is special in that it is completely contained by another conflicting
+ // Replacement. #4 ensures #3 hasn't messed up the conflicting range size.
std::vector<Range> Conflicts;
deduplicate(Input, Conflicts);
// No duplicates
- ASSERT_EQ(6u, Input.size());
+ ASSERT_EQ(8u, Input.size());
ASSERT_EQ(2u, Conflicts.size());
ASSERT_EQ(1u, Conflicts[0].getOffset());
- ASSERT_EQ(2u, Conflicts[0].getLength());
- ASSERT_EQ(4u, Conflicts[1].getOffset());
+ ASSERT_EQ(4u, Conflicts[0].getLength());
+ ASSERT_EQ(6u, Conflicts[1].getOffset());
ASSERT_EQ(2u, Conflicts[1].getLength());
}
}
OpenPOWER on IntegriCloud