blob: cc387b7fb7fc8cc1452c0ed5a2a1649c26ab1d74 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
//===- MemoryBufferRef.h - Memory Buffer Reference --------------*- C++ -*-===//
//
// 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 defines the MemoryBuffer interface.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_MEMORYBUFFERREF_H
#define LLVM_SUPPORT_MEMORYBUFFERREF_H
#include "llvm/ADT/StringRef.h"
namespace llvm {
class MemoryBuffer;
class MemoryBufferRef {
StringRef Buffer;
StringRef Identifier;
public:
MemoryBufferRef() = default;
MemoryBufferRef(const MemoryBuffer &Buffer);
MemoryBufferRef(StringRef Buffer, StringRef Identifier)
: Buffer(Buffer), Identifier(Identifier) {}
StringRef getBuffer() const { return Buffer; }
StringRef getBufferIdentifier() const { return Identifier; }
const char *getBufferStart() const { return Buffer.begin(); }
const char *getBufferEnd() const { return Buffer.end(); }
size_t getBufferSize() const { return Buffer.size(); }
/// Check pointer identity (not value) of identifier and data.
friend bool operator==(const MemoryBufferRef &LHS,
const MemoryBufferRef &RHS) {
return LHS.Buffer.begin() == RHS.Buffer.begin() &&
LHS.Buffer.end() == RHS.Buffer.end() &&
LHS.Identifier.begin() == RHS.Identifier.begin() &&
LHS.Identifier.end() == RHS.Identifier.end();
}
friend bool operator!=(const MemoryBufferRef &LHS,
const MemoryBufferRef &RHS) {
return !(LHS == RHS);
}
};
} // namespace llvm
#endif // LLVM_SUPPORT_MEMORYBUFFERREF_H
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
|