ScratchBuffer.h revision 353358
1193326Sed//===--- ScratchBuffer.h - Scratch space for forming tokens -----*- C++ -*-===// 2193326Sed// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6193326Sed// 7193326Sed//===----------------------------------------------------------------------===// 8193326Sed// 9193326Sed// This file defines the ScratchBuffer interface. 10193326Sed// 11193326Sed//===----------------------------------------------------------------------===// 12193326Sed 13280031Sdim#ifndef LLVM_CLANG_LEX_SCRATCHBUFFER_H 14280031Sdim#define LLVM_CLANG_LEX_SCRATCHBUFFER_H 15193326Sed 16193326Sed#include "clang/Basic/SourceLocation.h" 17193326Sed 18193326Sednamespace clang { 19193326Sed class SourceManager; 20193326Sed 21193326Sed/// ScratchBuffer - This class exposes a simple interface for the dynamic 22193326Sed/// construction of tokens. This is used for builtin macros (e.g. __LINE__) as 23193326Sed/// well as token pasting, etc. 24193326Sedclass ScratchBuffer { 25193326Sed SourceManager &SourceMgr; 26193326Sed char *CurBuffer; 27193326Sed SourceLocation BufferStartLoc; 28193326Sed unsigned BytesUsed; 29193326Sedpublic: 30193326Sed ScratchBuffer(SourceManager &SM); 31198092Srdivacky 32193326Sed /// getToken - Splat the specified text into a temporary MemoryBuffer and 33193326Sed /// return a SourceLocation that refers to the token. This is just like the 34193326Sed /// previous method, but returns a location that indicates the physloc of the 35193326Sed /// token. 36193326Sed SourceLocation getToken(const char *Buf, unsigned Len, const char *&DestPtr); 37198092Srdivacky 38193326Sedprivate: 39193326Sed void AllocScratchBuffer(unsigned RequestLen); 40193326Sed}; 41193326Sed 42193326Sed} // end namespace clang 43193326Sed 44193326Sed#endif 45