clang  6.0.0svn
ScratchBuffer.h
Go to the documentation of this file.
1 //===--- ScratchBuffer.h - Scratch space for forming tokens -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the ScratchBuffer interface.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LEX_SCRATCHBUFFER_H
15 #define LLVM_CLANG_LEX_SCRATCHBUFFER_H
16 
18 
19 namespace clang {
20  class SourceManager;
21 
22 /// ScratchBuffer - This class exposes a simple interface for the dynamic
23 /// construction of tokens. This is used for builtin macros (e.g. __LINE__) as
24 /// well as token pasting, etc.
26  SourceManager &SourceMgr;
27  char *CurBuffer;
28  SourceLocation BufferStartLoc;
29  unsigned BytesUsed;
30 public:
32 
33  /// getToken - Splat the specified text into a temporary MemoryBuffer and
34  /// return a SourceLocation that refers to the token. This is just like the
35  /// previous method, but returns a location that indicates the physloc of the
36  /// token.
37  SourceLocation getToken(const char *Buf, unsigned Len, const char *&DestPtr);
38 
39 private:
40  void AllocScratchBuffer(unsigned RequestLen);
41 };
42 
43 } // end namespace clang
44 
45 #endif
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...
const SourceManager & SM
Definition: Format.cpp:1337
Encodes a location in the source.
Dataflow Directional Tag Classes.
ScratchBuffer(SourceManager &SM)
Defines the clang::SourceLocation class and associated facilities.
ScratchBuffer - This class exposes a simple interface for the dynamic construction of tokens...
Definition: ScratchBuffer.h:25
This class handles loading and caching of source files into memory.