Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/Support/MemoryBuffer.h')
-rw-r--r--llvm/include/llvm/Support/MemoryBuffer.h32
1 files changed, 24 insertions, 8 deletions
diff --git a/llvm/include/llvm/Support/MemoryBuffer.h b/llvm/include/llvm/Support/MemoryBuffer.h
index 6385805eba1d..ed975c86c125 100644
--- a/llvm/include/llvm/Support/MemoryBuffer.h
+++ b/llvm/include/llvm/Support/MemoryBuffer.h
@@ -17,6 +17,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Alignment.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBufferRef.h"
@@ -90,9 +91,13 @@ public:
/// \param IsVolatile Set to true to indicate that the contents of the file
/// can change outside the user's control, e.g. when libclang tries to parse
/// while the user is editing/updating the file or if the file is on an NFS.
+ ///
+ /// \param Alignment Set to indicate that the buffer should be aligned to at
+ /// least the specified alignment.
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFile(const Twine &Filename, bool IsText = false,
- bool RequiresNullTerminator = true, bool IsVolatile = false);
+ bool RequiresNullTerminator = true, bool IsVolatile = false,
+ Optional<Align> Alignment = None);
/// Read all of the specified file into a MemoryBuffer as a stream
/// (i.e. until EOF reached). This is useful for special files that
@@ -105,7 +110,8 @@ public:
/// Since this is in the middle of a file, the buffer is not null terminated.
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getOpenFileSlice(sys::fs::file_t FD, const Twine &Filename, uint64_t MapSize,
- int64_t Offset, bool IsVolatile = false);
+ int64_t Offset, bool IsVolatile = false,
+ Optional<Align> Alignment = None);
/// Given an already-open file descriptor, read the file and return a
/// MemoryBuffer.
@@ -113,9 +119,13 @@ public:
/// \param IsVolatile Set to true to indicate that the contents of the file
/// can change outside the user's control, e.g. when libclang tries to parse
/// while the user is editing/updating the file or if the file is on an NFS.
+ ///
+ /// \param Alignment Set to indicate that the buffer should be aligned to at
+ /// least the specified alignment.
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
- bool RequiresNullTerminator = true, bool IsVolatile = false);
+ bool RequiresNullTerminator = true, bool IsVolatile = false,
+ Optional<Align> Alignment = None);
/// Open the specified memory range as a MemoryBuffer. Note that InputData
/// must be null terminated if RequiresNullTerminator is true.
@@ -138,12 +148,13 @@ public:
/// is "-".
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFileOrSTDIN(const Twine &Filename, bool IsText = false,
- bool RequiresNullTerminator = true);
+ bool RequiresNullTerminator = true,
+ Optional<Align> Alignment = None);
/// Map a subrange of the specified file as a MemoryBuffer.
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
- bool IsVolatile = false);
+ bool IsVolatile = false, Optional<Align> Alignment = None);
//===--------------------------------------------------------------------===//
// Provided for performance analysis.
@@ -188,18 +199,23 @@ public:
}
static ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
- getFile(const Twine &Filename, bool IsVolatile = false);
+ getFile(const Twine &Filename, bool IsVolatile = false,
+ Optional<Align> Alignment = None);
/// Map a subrange of the specified file as a WritableMemoryBuffer.
static ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
- bool IsVolatile = false);
+ bool IsVolatile = false, Optional<Align> Alignment = None);
/// Allocate a new MemoryBuffer of the specified size that is not initialized.
/// Note that the caller should initialize the memory allocated by this
/// method. The memory is owned by the MemoryBuffer object.
+ ///
+ /// \param Alignment Set to indicate that the buffer should be aligned to at
+ /// least the specified alignment.
static std::unique_ptr<WritableMemoryBuffer>
- getNewUninitMemBuffer(size_t Size, const Twine &BufferName = "");
+ getNewUninitMemBuffer(size_t Size, const Twine &BufferName = "",
+ Optional<Align> Alignment = None);
/// Allocate a new zero-initialized MemoryBuffer of the specified size. Note
/// that the caller need not initialize the memory allocated by this method.