X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FMemoryBuffer.h;h=cc65ca563b3e7f8fd83d8f20dc6b03da7a7cfbc6;hb=9130d115d6ec4e7b8e795b2f1e06ff6e660daa35;hp=827d896686dbbb23a3040670f80caecd36047b51;hpb=2292996e1a2c10bb62e1ebf8b0e658291bc7724d;p=oota-llvm.git diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index 827d896686d..cc65ca563b3 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -40,8 +40,8 @@ class MemoryBuffer { const char *BufferStart; // Start of the buffer. const char *BufferEnd; // End of the buffer. - MemoryBuffer(const MemoryBuffer &) LLVM_DELETED_FUNCTION; - MemoryBuffer &operator=(const MemoryBuffer &) LLVM_DELETED_FUNCTION; + MemoryBuffer(const MemoryBuffer &) = delete; + MemoryBuffer &operator=(const MemoryBuffer &) = delete; protected: MemoryBuffer() {} void init(const char *BufStart, const char *BufEnd, @@ -72,19 +72,15 @@ public: /// changing, e.g. when libclang tries to parse while the user is /// editing/updating the file. static ErrorOr> - getFile(Twine Filename, int64_t FileSize = -1, + getFile(const Twine &Filename, int64_t FileSize = -1, bool RequiresNullTerminator = true, bool IsVolatileSize = false); /// Given an already-open file descriptor, map some slice of it into a /// MemoryBuffer. The slice is specified by an \p Offset and \p MapSize. /// Since this is in the middle of a file, the buffer is not null terminated. - /// - /// \param IsVolatileSize Set to true to indicate that the file size may be - /// changing, e.g. when libclang tries to parse while the user is - /// editing/updating the file. static ErrorOr> - getOpenFileSlice(int FD, const char *Filename, uint64_t MapSize, - int64_t Offset, bool IsVolatileSize = false); + getOpenFileSlice(int FD, const Twine &Filename, uint64_t MapSize, + int64_t Offset); /// Given an already-open file descriptor, read the file and return a /// MemoryBuffer. @@ -93,33 +89,34 @@ public: /// changing, e.g. when libclang tries to parse while the user is /// editing/updating the file. static ErrorOr> - getOpenFile(int FD, const char *Filename, uint64_t FileSize, + getOpenFile(int FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator = true, bool IsVolatileSize = false); /// Open the specified memory range as a MemoryBuffer. Note that InputData /// must be null terminated if RequiresNullTerminator is true. - static MemoryBuffer *getMemBuffer(StringRef InputData, - StringRef BufferName = "", - bool RequiresNullTerminator = true); + static std::unique_ptr + getMemBuffer(StringRef InputData, StringRef BufferName = "", + bool RequiresNullTerminator = true); static std::unique_ptr getMemBuffer(MemoryBufferRef Ref, bool RequiresNullTerminator = true); /// Open the specified memory range as a MemoryBuffer, copying the contents /// and taking ownership of it. InputData does not have to be null terminated. - static MemoryBuffer *getMemBufferCopy(StringRef InputData, - StringRef BufferName = ""); + static std::unique_ptr + getMemBufferCopy(StringRef InputData, const Twine &BufferName = ""); /// Allocate a new zero-initialized MemoryBuffer of the specified size. Note /// that the caller need not initialize the memory allocated by this method. /// The memory is owned by the MemoryBuffer object. - static MemoryBuffer *getNewMemBuffer(size_t Size, StringRef BufferName = ""); + static std::unique_ptr + getNewMemBuffer(size_t Size, StringRef BufferName = ""); /// 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. - static MemoryBuffer *getNewUninitMemBuffer(size_t Size, - StringRef BufferName = ""); + static std::unique_ptr + getNewUninitMemBuffer(size_t Size, const Twine &BufferName = ""); /// Read all of stdin into a file buffer, and return it. static ErrorOr> getSTDIN(); @@ -127,7 +124,11 @@ public: /// Open the specified file as a MemoryBuffer, or open stdin if the Filename /// is "-". static ErrorOr> - getFileOrSTDIN(StringRef Filename, int64_t FileSize = -1); + getFileOrSTDIN(const Twine &Filename, int64_t FileSize = -1); + + /// Map a subrange of the the specified file as a MemoryBuffer. + static ErrorOr> + getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset); //===--------------------------------------------------------------------===// // Provided for performance analysis.