//===--- ScratchBuffer.cpp - Scratch space for forming tokens -------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the ScratchBuffer interface. // //===----------------------------------------------------------------------===// #include "clang/Lex/ScratchBuffer.h" #include "clang/Basic/SourceManager.h" #include "llvm/Support/MemoryBuffer.h" #include <cstring> usingnamespaceclang; // ScratchBufSize - The size of each chunk of scratch memory. Slightly less //than a page, almost certainly enough for anything. :) static const unsigned ScratchBufSize = …; ScratchBuffer::ScratchBuffer(SourceManager &SM) : … { … } /// getToken - Splat the specified text into a temporary MemoryBuffer and /// return a SourceLocation that refers to the token. This is just like the /// method below, but returns a location that indicates the physloc of the /// token. SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len, const char *&DestPtr) { … } void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) { … }