diff include/llvm/Support/MemoryBuffer.h @ 120:1172e4bd9c6f

update 4.0.0
author mir3636
date Fri, 25 Nov 2016 19:14:25 +0900
parents 7d135dc70f03
children 803732b1fca8
line wrap: on
line diff
--- a/include/llvm/Support/MemoryBuffer.h	Tue Jan 26 22:56:36 2016 +0900
+++ b/include/llvm/Support/MemoryBuffer.h	Fri Nov 25 19:14:25 2016 +0900
@@ -56,9 +56,7 @@
 
   /// Return an identifier for this buffer, typically the filename it was read
   /// from.
-  virtual const char *getBufferIdentifier() const {
-    return "Unknown buffer";
-  }
+  virtual StringRef getBufferIdentifier() const { return "Unknown buffer"; }
 
   /// Open the specified file as a MemoryBuffer, returning a new MemoryBuffer
   /// if successful, otherwise returning null. If FileSize is specified, this
@@ -72,6 +70,12 @@
   getFile(const Twine &Filename, int64_t FileSize = -1,
           bool RequiresNullTerminator = true, bool IsVolatileSize = false);
 
+  /// Read all of the specified file into a MemoryBuffer as a stream
+  /// (i.e. until EOF reached). This is useful for special files that
+  /// look like a regular file but have 0 size (e.g. /proc/cpuinfo on Linux).
+  static ErrorOr<std::unique_ptr<MemoryBuffer>>
+  getFileAsStream(const Twine &Filename);
+
   /// 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.