LLVM  14.0.0git
SmallVectorMemoryBuffer.h
Go to the documentation of this file.
1 //===- SmallVectorMemoryBuffer.h --------------------------------*- 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 declares a wrapper class to hold the memory into which an
10 // object will be generated.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_SUPPORT_SMALLVECTORMEMORYBUFFER_H
15 #define LLVM_SUPPORT_SMALLVECTORMEMORYBUFFER_H
16 
17 #include "llvm/ADT/SmallVector.h"
20 
21 namespace llvm {
22 
23 /// SmallVector-backed MemoryBuffer instance.
24 ///
25 /// This class enables efficient construction of MemoryBuffers from SmallVector
26 /// instances. This is useful for MCJIT and Orc, where object files are streamed
27 /// into SmallVectors, then inspected using ObjectFile (which takes a
28 /// MemoryBuffer).
30 public:
31  /// Construct an SmallVectorMemoryBuffer from the given SmallVector
32  /// r-value.
33  ///
34  /// FIXME: It'd be nice for this to be a non-templated constructor taking a
35  /// SmallVectorImpl here instead of a templated one taking a SmallVector<N>,
36  /// but SmallVector's move-construction/assignment currently only take
37  /// SmallVectors. If/when that is fixed we can simplify this constructor and
38  /// the following one.
40  : SV(std::move(SV)), BufferName("<in-memory object>") {
41  init(this->SV.begin(), this->SV.end(), false);
42  }
43 
44  /// Construct a named SmallVectorMemoryBuffer from the given
45  /// SmallVector r-value and StringRef.
47  : SV(std::move(SV)), BufferName(std::string(Name)) {
48  init(this->SV.begin(), this->SV.end(), false);
49  }
50 
51  // Key function.
52  ~SmallVectorMemoryBuffer() override;
53 
54  StringRef getBufferIdentifier() const override { return BufferName; }
55 
56  BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; }
57 
58 private:
60  std::string BufferName;
61 };
62 
63 } // namespace llvm
64 
65 #endif
MemoryBuffer.h
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::SmallVector< char, 0 >
llvm::SmallVectorMemoryBuffer
SmallVector-backed MemoryBuffer instance.
Definition: SmallVectorMemoryBuffer.h:29
llvm::MemoryBuffer
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:50
llvm::MemoryBuffer::init
void init(const char *BufStart, const char *BufEnd, bool RequiresNullTerminator)
init - Initialize this MemoryBuffer as a reference to externally allocated memory,...
Definition: MemoryBuffer.cpp:46
llvm::SmallVectorMemoryBuffer::SmallVectorMemoryBuffer
SmallVectorMemoryBuffer(SmallVectorImpl< char > &&SV, StringRef Name)
Construct a named SmallVectorMemoryBuffer from the given SmallVector r-value and StringRef.
Definition: SmallVectorMemoryBuffer.h:46
llvm::SmallVectorMemoryBuffer::~SmallVectorMemoryBuffer
~SmallVectorMemoryBuffer() override
Definition: MemoryBuffer.cpp:546
llvm::MemoryBuffer::BufferKind
BufferKind
The kind of memory backing used to support the MemoryBuffer.
Definition: MemoryBuffer.h:146
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1609
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::SmallVectorMemoryBuffer::SmallVectorMemoryBuffer
SmallVectorMemoryBuffer(SmallVectorImpl< char > &&SV)
Construct an SmallVectorMemoryBuffer from the given SmallVector r-value.
Definition: SmallVectorMemoryBuffer.h:39
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:838
SmallVector.h
llvm::SmallVectorMemoryBuffer::getBufferKind
BufferKind getBufferKind() const override
Return information on the memory mechanism used to support the MemoryBuffer.
Definition: SmallVectorMemoryBuffer.h:56
llvm::SmallVectorImpl< char >
raw_ostream.h
llvm::SmallVectorMemoryBuffer::getBufferIdentifier
StringRef getBufferIdentifier() const override
Return an identifier for this buffer, typically the filename it was read from.
Definition: SmallVectorMemoryBuffer.h:54
llvm::MemoryBuffer::MemoryBuffer_Malloc
@ MemoryBuffer_Malloc
Definition: MemoryBuffer.h:147
SpecialSubKind::string
@ string