[Lexer] Introduce Lexer::getLocForStartOfToken() that returns the location at the start of the token that a given offset points to.

Swift SVN r8281
This commit is contained in:
Argyrios Kyrtzidis
2013-09-16 18:41:16 +00:00
parent e7af4d6c72
commit 5db368ce7b
4 changed files with 116 additions and 2 deletions

View File

@@ -110,6 +110,11 @@ public:
/// \brief Returns the distance in bytes between the given source locations.
unsigned getByteDistance(SourceLoc Start, SourceLoc End) const;
/// Returns the SourceLoc for the byte offset in the specified buffer.
SourceLoc getLocForOffset(unsigned BufferID, unsigned Offset) const {
return getLocForBufferStart(BufferID).getAdvancedLoc(Offset);
}
std::pair<unsigned, unsigned> getLineAndColumn(SourceLoc Loc,
int BufferID = -1) const {
assert(Loc.isValid());