clang: lib/Lex/ScratchBuffer.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

15#include "llvm/Support/MemoryBuffer.h"

16#include

17using namespace clang;

18

19

20

22

24 : SourceMgr(SM), CurBuffer(nullptr) {

25

27}

28

29

30

31

32

34 const char *&DestPtr) {

36 AllocScratchBuffer(Len+2);

37 else {

38

39

44 }

45

46

47

48 CurBuffer[BytesUsed++] = '\n';

49

50

51 DestPtr = CurBuffer+BytesUsed;

52

53

54 memcpy(CurBuffer+BytesUsed, Buf, Len);

55

56

57 BytesUsed += Len+1;

58

59

60

61

62 CurBuffer[BytesUsed-1] = '\0';

63

65}

66

67void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) {

68

69

70

73

74

75

76 std::unique_ptrllvm::WritableMemoryBuffer OwnBuf =

77 llvm::WritableMemoryBuffer::getNewMemBuffer(RequestLen,

78 "");

79 CurBuffer = OwnBuf->getBufferStart();

82 BytesUsed = 0;

83}

static const unsigned ScratchBufSize

Defines the SourceManager interface.

__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)

An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...

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...

ScratchBuffer(SourceManager &SM)

Encodes a location in the source.

SourceLocation getLocWithOffset(IntTy Offset) const

Return a source location with the specified offset from this SourceLocation.

This class handles loading and caching of source files into memory.

FileID getFileID(SourceLocation SpellingLoc) const

Return the FileID for a SourceLocation.

FileID createFileID(FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)

Create a new FileID that represents the specified file being #included from the specified IncludePosi...

SourceLocation getLocForStartOfFile(FileID FID) const

Return the source location corresponding to the first byte of the specified file.

const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const

LineOffsetMapping SourceLineCache

A bump pointer allocated array of offsets for each source line.

const ContentCache & getContentCache() const

Mapping of line offsets into a source file.

const FileInfo & getFile() const

The JSON file list parser is used to communicate input to InstallAPI.