Output lints by location in file
Sort lints by their location within the file.
Fix: 134781118
Test: Visual
Change-Id: I5beed3a37e19cd03cffcf3f0f42848ec56ff7b04
diff --git a/Location.cpp b/Location.cpp
index 2d834fb..0bff1b2 100644
--- a/Location.cpp
+++ b/Location.cpp
@@ -17,6 +17,7 @@
#include "Location.h"
#include <android-base/logging.h>
+#include <tuple>
namespace android {
@@ -40,11 +41,7 @@
}
bool Position::operator<(const Position& pos) const {
- CHECK(inSameFile(*this, pos)) << "Cannot compare positions in different files";
- if (mLine == pos.mLine) {
- return mColumn < pos.mColumn;
- }
- return mLine < pos.mLine;
+ return std::tie(mFilename, mLine, mColumn) < std::tie(pos.mFilename, pos.mLine, pos.mColumn);
}
std::ostream& operator<<(std::ostream& ostr, const Position& pos) {
@@ -91,9 +88,7 @@
}
bool Location::operator<(const Location& loc) const {
- CHECK(inSameFile(*this, loc)) << "Cannot compare locations in different files";
- CHECK(!intersect(*this, loc));
- return mEnd < loc.mBegin;
+ return std::tie(mBegin, mEnd) < std::tie(loc.mBegin, loc.mEnd);
}
std::ostream& operator<<(std::ostream& ostr, const Location& loc) {