clang  14.0.0git
ScratchBuffer.h
Go to the documentation of this file.
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 
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.
25  SourceManager &SourceMgr;
26  char *CurBuffer;
27  SourceLocation BufferStartLoc;
28  unsigned BytesUsed;
29 public:
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
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:626
SourceLocation.h
clang::ScratchBuffer
ScratchBuffer - This class exposes a simple interface for the dynamic construction of tokens.
Definition: ScratchBuffer.h:24
clang::ScratchBuffer::getToken
SourceLocation getToken(const char *Buf, unsigned Len, const char *&DestPtr)
getToken - Splat the specified text into a temporary MemoryBuffer and return a SourceLocation that re...
Definition: ScratchBuffer.cpp:33
clang
Definition: CalledOnceCheck.h:17
clang::ScratchBuffer::ScratchBuffer
ScratchBuffer(SourceManager &SM)
Definition: ScratchBuffer.cpp:23
SM
#define SM(sm)
Definition: Cuda.cpp:78