Skip to content

Commit 6aa9e67

Browse files
author
Christian Parpart
committed
liblangutil: SourceLocation: do not store sourceName but pointer to underlying CharStream (which knows about the source's filename)
1 parent d08d3ee commit 6aa9e67

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

liblangutil/SourceLocation.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ struct SourceLocation
6969

7070
bool isEmpty() const { return start == -1 && end == -1; }
7171

72+
bool hasSource() const noexcept { return charStream; }
73+
bool hasSourceName() const noexcept { return charStream && !charStream->filename().empty(); }
74+
75+
std::string const& sourceName() const
76+
{
77+
static std::string const empty;
78+
return charStream ? charStream->filename() : empty;
79+
}
80+
7281
int start;
7382
int end;
7483
std::shared_ptr<CharStream> source;

0 commit comments

Comments
 (0)