Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 14 | pmbaty | 1 | //===--- ScratchBuffer.h - Scratch space for forming tokens -----*- C++ -*-===// | 
| 2 | // | ||
| 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 | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | // | ||
| 9 | //  This file defines the ScratchBuffer interface. | ||
| 10 | // | ||
| 11 | //===----------------------------------------------------------------------===// | ||
| 12 | |||
| 13 | #ifndef LLVM_CLANG_LEX_SCRATCHBUFFER_H | ||
| 14 | #define LLVM_CLANG_LEX_SCRATCHBUFFER_H | ||
| 15 | |||
| 16 | #include "clang/Basic/SourceLocation.h" | ||
| 17 | |||
| 18 | namespace clang { | ||
| 19 | class SourceManager; | ||
| 20 | |||
| 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. | ||
| 24 | class ScratchBuffer { | ||
| 25 | SourceManager &SourceMgr; | ||
| 26 | char *CurBuffer; | ||
| 27 |   SourceLocation BufferStartLoc; | ||
| 28 | unsigned BytesUsed; | ||
| 29 | public: | ||
| 30 | ScratchBuffer(SourceManager &SM); | ||
| 31 | |||
| 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 | ||
| 35 |   /// token. | ||
| 36 | SourceLocation getToken(const char *Buf, unsigned Len, const char *&DestPtr); | ||
| 37 | |||
| 38 | private: | ||
| 39 | void AllocScratchBuffer(unsigned RequestLen); | ||
| 40 | }; | ||
| 41 | |||
| 42 | } // end namespace clang | ||
| 43 | |||
| 44 | #endif |