liblangutil: Adds a convenience helper method SourceLocation::contains(int _pos).

This commit is contained in:
Christian Parpart 2021-03-24 12:48:56 +01:00 committed by chriseth
parent 86a7e19879
commit 35a81073b8

View File

@ -59,6 +59,13 @@ struct SourceLocation
return start <= _other.start && _other.end <= end; return start <= _other.start && _other.end <= end;
} }
bool containsOffset(int _pos) const
{
if (!hasText() || _pos < 0)
return false;
return start <= _pos && _pos < end;
}
bool intersects(SourceLocation const& _other) const bool intersects(SourceLocation const& _other) const
{ {
if (!hasText() || !_other.hasText() || !equalSources(_other)) if (!hasText() || !_other.hasText() || !equalSources(_other))