Skip to content

Commit 84e09a8

Browse files
committed
Add == for SourceRange and CharSourceRange. NFC.
1 parent eeac42c commit 84e09a8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/swift/Basic/SourceLoc.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ class SourceRange {
9696
bool isValid() const { return Start.isValid(); }
9797
bool isInvalid() const { return !isValid(); }
9898

99+
bool operator==(const SourceRange &other) const {
100+
return Start == other.Start && End == other.End;
101+
}
102+
bool operator!=(const SourceRange &other) const { return !operator==(other); }
103+
99104
/// Print out the SourceRange. If the locations are in the same buffer
100105
/// as specified by LastBufferID, then we don't print the filename. If not,
101106
/// we do print the filename, and then update LastBufferID with the BufferID
@@ -134,6 +139,13 @@ class CharSourceRange {
134139
bool isValid() const { return Start.isValid(); }
135140
bool isInvalid() const { return !isValid(); }
136141

142+
bool operator==(const CharSourceRange &other) const {
143+
return Start == other.Start && ByteLength == other.ByteLength;
144+
}
145+
bool operator!=(const CharSourceRange &other) const {
146+
return !operator==(other);
147+
}
148+
137149
SourceLoc getStart() const { return Start; }
138150
SourceLoc getEnd() const { return Start.getAdvancedLocOrInvalid(ByteLength); }
139151

0 commit comments

Comments
 (0)