1 //===--- ScratchBuffer.h - Scratch space for forming tokens -----*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines the ScratchBuffer interface.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_LEX_SCRATCHBUFFER_H
14 #define LLVM_CLANG_LEX_SCRATCHBUFFER_H
16 #include "clang/Basic/SourceLocation.h"
21 /// ScratchBuffer - This class exposes a simple interface for the dynamic
22 /// construction of tokens. This is used for builtin macros (e.g. __LINE__) as
23 /// well as token pasting, etc.
25 SourceManager &SourceMgr;
27 SourceLocation BufferStartLoc;
30 ScratchBuffer(SourceManager &SM);
32 /// getToken - Splat the specified text into a temporary MemoryBuffer and
33 /// return a SourceLocation that refers to the token. This is just like the
34 /// previous method, but returns a location that indicates the physloc of the
36 SourceLocation getToken(const char *Buf, unsigned Len, const char *&DestPtr);
39 void AllocScratchBuffer(unsigned RequestLen);
42 } // end namespace clang