Use LineColumn type.

This commit is contained in:
chriseth
2021-11-30 00:08:22 +01:00
parent 622e89649f
commit 86ce5f1da5
4 changed files with 23 additions and 12 deletions
+19
View File
@@ -119,4 +119,23 @@ SourceLocation parseSourceLocation(
/// Stream output for Location (used e.g. in boost exceptions).
std::ostream& operator<<(std::ostream& _out, SourceLocation const& _location);
/**
* Alternative, line-column-based representation for source locations.
* Both line and column are zero-based.
* If used as a range, the second location is considered exclusive.
* Negative values are invalid.
*/
struct LineColumn
{
/// Line value, can be between zero and number of `\n` characters in the source file.
int line = -1;
/// Column value, can be between zero and number of characters in the line (inclusive).
int column = -1;
LineColumn() = default;
explicit LineColumn(int _line, int _column): line(_line), column(_column) {}
};
}