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

This commit is contained in:
Christian Parpart
2021-10-14 17:35:03 +02:00
committed by chriseth
parent 86a7e19879
commit 35a81073b8
+7
View File
@@ -59,6 +59,13 @@ struct SourceLocation
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
{
if (!hasText() || !_other.hasText() || !equalSources(_other))