LLVM 22.0.0git
MemoryBufferRef.h
Go to the documentation of this file.
1//===- MemoryBufferRef.h - Memory Buffer Reference --------------*- 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 MemoryBuffer interface.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_SUPPORT_MEMORYBUFFERREF_H
14#define LLVM_SUPPORT_MEMORYBUFFERREF_H
15
16#include "llvm/ADT/StringRef.h"
18
19namespace llvm {
20
21class MemoryBuffer;
22
24 StringRef Buffer;
25 StringRef Identifier;
26
27public:
28 MemoryBufferRef() = default;
31 : Buffer(Buffer), Identifier(Identifier) {}
32
33 StringRef getBuffer() const { return Buffer; }
34 StringRef getBufferIdentifier() const { return Identifier; }
35
36 const char *getBufferStart() const { return Buffer.begin(); }
37 const char *getBufferEnd() const { return Buffer.end(); }
38 size_t getBufferSize() const { return Buffer.size(); }
39
40 /// Check pointer identity (not value) of identifier and data.
41 friend bool operator==(const MemoryBufferRef &LHS,
42 const MemoryBufferRef &RHS) {
43 return LHS.Buffer.begin() == RHS.Buffer.begin() &&
44 LHS.Buffer.end() == RHS.Buffer.end() &&
45 LHS.Identifier.begin() == RHS.Identifier.begin() &&
46 LHS.Identifier.end() == RHS.Identifier.end();
47 }
48
49 friend bool operator!=(const MemoryBufferRef &LHS,
50 const MemoryBufferRef &RHS) {
51 return !(LHS == RHS);
52 }
53};
54
55} // namespace llvm
56
57#endif // LLVM_SUPPORT_MEMORYBUFFERREF_H
#define LLVM_ABI
Definition Compiler.h:213
Value * RHS
Value * LHS
MemoryBufferRef(StringRef Buffer, StringRef Identifier)
size_t getBufferSize() const
StringRef getBufferIdentifier() const
const char * getBufferStart() const
StringRef getBuffer() const
friend bool operator==(const MemoryBufferRef &LHS, const MemoryBufferRef &RHS)
Check pointer identity (not value) of identifier and data.
friend bool operator!=(const MemoryBufferRef &LHS, const MemoryBufferRef &RHS)
const char * getBufferEnd() const
This interface provides simple read-only access to a block of memory, and provides simple methods for...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This is an optimization pass for GlobalISel generic memory operations.