]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/tools/clang/include/clang/Lex/ScratchBuffer.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / tools / clang / include / clang / Lex / ScratchBuffer.h
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_SCRATCHBUFFER_H
15 #define LLVM_CLANG_SCRATCHBUFFER_H
16
17 #include "clang/Basic/SourceLocation.h"
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.
25 class ScratchBuffer {
26   SourceManager &SourceMgr;
27   char *CurBuffer;
28   SourceLocation BufferStartLoc;
29   unsigned BytesUsed;
30 public:
31   ScratchBuffer(SourceManager &SM);
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