ScratchBuffer.h revision 198092
1193326Sed//===--- ScratchBuffer.h - Scratch space for forming tokens -----*- C++ -*-===//
2193326Sed//
3193326Sed//                     The LLVM Compiler Infrastructure
4193326Sed//
5193326Sed// This file is distributed under the University of Illinois Open Source
6193326Sed// License. See LICENSE.TXT for details.
7193326Sed//
8193326Sed//===----------------------------------------------------------------------===//
9193326Sed//
10193326Sed//  This file defines the ScratchBuffer interface.
11193326Sed//
12193326Sed//===----------------------------------------------------------------------===//
13193326Sed
14193326Sed#ifndef LLVM_CLANG_SCRATCHBUFFER_H
15193326Sed#define LLVM_CLANG_SCRATCHBUFFER_H
16193326Sed
17193326Sed#include "clang/Basic/SourceLocation.h"
18193326Sed
19193326Sednamespace clang {
20193326Sed  class SourceManager;
21193326Sed
22193326Sed/// ScratchBuffer - This class exposes a simple interface for the dynamic
23193326Sed/// construction of tokens.  This is used for builtin macros (e.g. __LINE__) as
24193326Sed/// well as token pasting, etc.
25193326Sedclass ScratchBuffer {
26193326Sed  SourceManager &SourceMgr;
27193326Sed  char *CurBuffer;
28193326Sed  SourceLocation BufferStartLoc;
29193326Sed  unsigned BytesUsed;
30193326Sedpublic:
31193326Sed  ScratchBuffer(SourceManager &SM);
32198092Srdivacky
33193326Sed  /// getToken - Splat the specified text into a temporary MemoryBuffer and
34193326Sed  /// return a SourceLocation that refers to the token.  This is just like the
35193326Sed  /// previous method, but returns a location that indicates the physloc of the
36193326Sed  /// token.
37193326Sed  SourceLocation getToken(const char *Buf, unsigned Len, const char *&DestPtr);
38198092Srdivacky
39193326Sedprivate:
40193326Sed  void AllocScratchBuffer(unsigned RequestLen);
41193326Sed};
42193326Sed
43193326Sed} // end namespace clang
44193326Sed
45193326Sed#endif
46