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
17#include "clang/Basic/SourceLocation.h"
18
19namespace 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.
25class ScratchBuffer {
26  SourceManager &SourceMgr;
27  char *CurBuffer;
28  SourceLocation BufferStartLoc;
29  unsigned BytesUsed;
30public:
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
39private:
40  void AllocScratchBuffer(unsigned RequestLen);
41};
42
43} // end namespace clang
44
45#endif
46