Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:58

0001 //===--- ScratchBuffer.h - Scratch space for forming tokens -----*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 //  This file defines the ScratchBuffer interface.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_CLANG_LEX_SCRATCHBUFFER_H
0014 #define LLVM_CLANG_LEX_SCRATCHBUFFER_H
0015 
0016 #include "clang/Basic/SourceLocation.h"
0017 
0018 namespace clang {
0019   class SourceManager;
0020 
0021 /// ScratchBuffer - This class exposes a simple interface for the dynamic
0022 /// construction of tokens.  This is used for builtin macros (e.g. __LINE__) as
0023 /// well as token pasting, etc.
0024 class ScratchBuffer {
0025   SourceManager &SourceMgr;
0026   char *CurBuffer;
0027   SourceLocation BufferStartLoc;
0028   unsigned BytesUsed;
0029 public:
0030   ScratchBuffer(SourceManager &SM);
0031 
0032   /// getToken - Splat the specified text into a temporary MemoryBuffer and
0033   /// return a SourceLocation that refers to the token.  This is just like the
0034   /// previous method, but returns a location that indicates the physloc of the
0035   /// token.
0036   SourceLocation getToken(const char *Buf, unsigned Len, const char *&DestPtr);
0037 
0038 private:
0039   void AllocScratchBuffer(unsigned RequestLen);
0040 };
0041 
0042 } // end namespace clang
0043 
0044 #endif