r188304 - Have Range::overlapsWith use positive logic
Edwin Vane
edwin.vane at intel.com
Tue Aug 13 11:11:17 PDT 2013
Author: revane
Date: Tue Aug 13 13:11:16 2013
New Revision: 188304
URL: http://llvm.org/viewvc/llvm-project?rev=188304&view=rev
Log:
Have Range::overlapsWith use positive logic
Improved test to catch missing case.
Modified:
cfe/trunk/include/clang/Tooling/Refactoring.h
cfe/trunk/unittests/Tooling/RefactoringTest.cpp
Modified: cfe/trunk/include/clang/Tooling/Refactoring.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring.h?rev=188304&r1=188303&r2=188304&view=diff
==============================================================================
--- cfe/trunk/include/clang/Tooling/Refactoring.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring.h Tue Aug 13 13:11:16 2013
@@ -48,9 +48,7 @@ public:
/// @{
/// \brief Whether this range overlaps with \p RHS or not.
bool overlapsWith(Range RHS) const {
- if ((Offset + Length) <= RHS.Offset || Offset >= (RHS.Offset + RHS.Length))
- return false;
- return true;
+ return Offset + Length > RHS.Offset && Offset < RHS.Offset + RHS.Length;
}
/// \brief Whether this range contains \p RHS or not.
Modified: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringTest.cpp?rev=188304&r1=188303&r2=188304&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp Tue Aug 13 13:11:16 2013
@@ -353,6 +353,7 @@ TEST(Range, overlaps) {
EXPECT_FALSE(Range(10, 10).overlapsWith(Range(0, 10)));
EXPECT_FALSE(Range(0, 10).overlapsWith(Range(10, 10)));
EXPECT_TRUE(Range(0, 10).overlapsWith(Range(2, 6)));
+ EXPECT_TRUE(Range(2, 6).overlapsWith(Range(0, 10)));
}
TEST(Range, contains) {
More information about the cfe-commits
mailing list