16 #include "llvm/Support/MemoryBuffer.h"
18 using namespace clang;
35 const char *&DestPtr) {
37 AllocScratchBuffer(Len+2);
43 .getFile().getContentCache());
49 CurBuffer[BytesUsed++] =
'\n';
52 DestPtr = CurBuffer+BytesUsed;
55 memcpy(CurBuffer+BytesUsed, Buf, Len);
63 CurBuffer[BytesUsed-1] =
'\0';
68 void ScratchBuffer::AllocScratchBuffer(
unsigned RequestLen) {
77 std::unique_ptr<llvm::MemoryBuffer> OwnBuf =
78 llvm::MemoryBuffer::getNewMemBuffer(RequestLen,
"<scratch space>");
79 llvm::MemoryBuffer &Buf = *OwnBuf;
82 CurBuffer =
const_cast<char*
>(Buf.getBufferStart());
SourceLocation getToken(const char *Buf, unsigned Len, const char *&DestPtr)
getToken - Splat the specified text into a temporary MemoryBuffer and return a SourceLocation that re...
Defines the SourceManager interface.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
One instance of this struct is kept for every file loaded or used.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
static const unsigned ScratchBufSize
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, unsigned LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
Encodes a location in the source.
unsigned * SourceLineCache
A bump pointer allocated array of offsets for each source line.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
ScratchBuffer(SourceManager &SM)
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
This class handles loading and caching of source files into memory.