diff options
Diffstat (limited to 'lib/Lex/ScratchBuffer.cpp')
-rw-r--r-- | lib/Lex/ScratchBuffer.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/Lex/ScratchBuffer.cpp b/lib/Lex/ScratchBuffer.cpp index 695a5365fa..9253bc0944 100644 --- a/lib/Lex/ScratchBuffer.cpp +++ b/lib/Lex/ScratchBuffer.cpp @@ -30,10 +30,14 @@ ScratchBuffer::ScratchBuffer(SourceManager &SM) : SourceMgr(SM), CurBuffer(0) { /// return a SourceLocation that refers to the token. This is just like the /// method below, but returns a location that indicates the physloc of the /// token. -SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len) { +SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len, + const char *&DestPtr) { if (BytesUsed+Len > ScratchBufSize) AllocScratchBuffer(Len); + // Return a pointer to the character data. + DestPtr = CurBuffer+BytesUsed; + // Copy the token data into the buffer. memcpy(CurBuffer+BytesUsed, Buf, Len); @@ -43,16 +47,6 @@ SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len) { return BufferStartLoc.getFileLocWithOffset(BytesUsed-Len); } - -/// getToken - Splat the specified text into a temporary MemoryBuffer and -/// return a SourceLocation that refers to the token. The SourceLoc value -/// gives a virtual location that the token will appear to be from. -SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len, - SourceLocation SourceLoc) { - // Map the physloc to the specified sourceloc. - return SourceMgr.createInstantiationLoc(getToken(Buf, Len), SourceLoc, Len); -} - void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) { // Only pay attention to the requested length if it is larger than our default // page size. If it is, we allocate an entire chunk for it. This is to |