[llvm] r296415 - [PDB] Make streams carry their own endianness.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 16:04:09 PST 2017


Author: zturner
Date: Mon Feb 27 18:04:07 2017
New Revision: 296415

URL: http://llvm.org/viewvc/llvm-project?rev=296415&view=rev
Log:
[PDB] Make streams carry their own endianness.

Before the endianness was specified on each call to read
or write of the StreamReader / StreamWriter, but in practice
it's extremely rare for streams to have data encoded in
multiple different endiannesses, so we should optimize for the
99% use case.

This makes the code cleaner and more general, but otherwise
has NFC.

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
    llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h
    llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
    llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDeserializer.h
    llvm/trunk/include/llvm/DebugInfo/CodeView/TypeSerializer.h
    llvm/trunk/include/llvm/DebugInfo/MSF/BinaryByteStream.h
    llvm/trunk/include/llvm/DebugInfo/MSF/BinaryItemStream.h
    llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStream.h
    llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamReader.h
    llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamRef.h
    llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamWriter.h
    llvm/trunk/include/llvm/DebugInfo/MSF/MappedBlockStream.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/trunk/lib/DebugInfo/CodeView/CVTypeDumper.cpp
    llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
    llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
    llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp
    llvm/trunk/lib/DebugInfo/CodeView/TypeSerializer.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/HashTable.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/ModStream.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/SymbolStream.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
    llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp
    llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
    llvm/trunk/unittests/DebugInfo/PDB/HashTableTest.cpp
    llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp
    llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h Mon Feb 27 18:04:07 2017
@@ -59,9 +59,9 @@ public:
 
   template <typename T> Error mapInteger(T &Value) {
     if (isWriting())
-      return Writer->writeInteger(Value, llvm::support::little);
+      return Writer->writeInteger(Value);
 
-    return Reader->readInteger(Value, llvm::support::little);
+    return Reader->readInteger(Value);
   }
 
   template <typename T> Error mapEnum(T &Value) {
@@ -93,7 +93,7 @@ public:
     SizeType Size;
     if (isWriting()) {
       Size = static_cast<SizeType>(Items.size());
-      if (auto EC = Writer->writeInteger(Size, llvm::support::little))
+      if (auto EC = Writer->writeInteger(Size))
         return EC;
 
       for (auto &X : Items) {
@@ -101,7 +101,7 @@ public:
           return EC;
       }
     } else {
-      if (auto EC = Reader->readInteger(Size, llvm::support::little))
+      if (auto EC = Reader->readInteger(Size))
         return EC;
       for (SizeType I = 0; I < Size; ++I) {
         typename T::value_type Item;

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h Mon Feb 27 18:04:07 2017
@@ -25,7 +25,8 @@ class SymbolVisitorDelegate;
 class SymbolDeserializer : public SymbolVisitorCallbacks {
   struct MappingInfo {
     explicit MappingInfo(ArrayRef<uint8_t> RecordData)
-        : Stream(RecordData), Reader(Stream), Mapping(Reader) {}
+        : Stream(RecordData, llvm::support::little), Reader(Stream),
+          Mapping(Reader) {}
 
     BinaryByteStream Stream;
     BinaryStreamReader Reader;

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h Mon Feb 27 18:04:07 2017
@@ -12,18 +12,19 @@
 
 #include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h"
 #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
-#include "llvm/DebugInfo/MSF/BinaryByteStream.h"
-#include "llvm/DebugInfo/MSF/BinaryStreamWriter.h"
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/DebugInfo/MSF/BinaryByteStream.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamWriter.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Error.h"
 
 namespace llvm {
+class BinaryStreamWriter;
 namespace codeview {
 
 class SymbolSerializer : public SymbolVisitorCallbacks {

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDeserializer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDeserializer.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDeserializer.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDeserializer.h Mon Feb 27 18:04:07 2017
@@ -29,7 +29,8 @@ namespace codeview {
 class TypeDeserializer : public TypeVisitorCallbacks {
   struct MappingInfo {
     explicit MappingInfo(ArrayRef<uint8_t> RecordData)
-        : Stream(RecordData), Reader(Stream), Mapping(Reader) {}
+        : Stream(RecordData, llvm::support::little), Reader(Stream),
+          Mapping(Reader) {}
 
     BinaryByteStream Stream;
     BinaryStreamReader Reader;

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeSerializer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeSerializer.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeSerializer.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeSerializer.h Mon Feb 27 18:04:07 2017
@@ -109,7 +109,7 @@ private:
   Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
     assert(CVR.Kind == static_cast<TypeLeafKind>(Record.getKind()));
 
-    if (auto EC = Writer.writeEnum(CVR.Kind, llvm::support::little))
+    if (auto EC = Writer.writeEnum(CVR.Kind))
       return EC;
 
     if (auto EC = Mapping.visitKnownMember(CVR, Record))

Modified: llvm/trunk/include/llvm/DebugInfo/MSF/BinaryByteStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/MSF/BinaryByteStream.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/MSF/BinaryByteStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/MSF/BinaryByteStream.h Mon Feb 27 18:04:07 2017
@@ -32,9 +32,12 @@ namespace llvm {
 class BinaryByteStream : public BinaryStream {
 public:
   BinaryByteStream() = default;
-  BinaryByteStream(ArrayRef<uint8_t> Data) : Data(Data) {}
-  BinaryByteStream(StringRef Data)
-      : Data(Data.bytes_begin(), Data.bytes_end()) {}
+  BinaryByteStream(ArrayRef<uint8_t> Data, llvm::support::endianness Endian)
+      : Endian(Endian), Data(Data) {}
+  BinaryByteStream(StringRef Data, llvm::support::endianness Endian)
+      : Endian(Endian), Data(Data.bytes_begin(), Data.bytes_end()) {}
+
+  llvm::support::endianness getEndian() const override { return Endian; }
 
   Error readBytes(uint32_t Offset, uint32_t Size,
                   ArrayRef<uint8_t> &Buffer) override {
@@ -67,6 +70,7 @@ public:
   }
 
 protected:
+  llvm::support::endianness Endian;
   ArrayRef<uint8_t> Data;
 };
 
@@ -76,8 +80,10 @@ protected:
 /// will never cause a copy.
 class MemoryBufferByteStream : public BinaryByteStream {
 public:
-  explicit MemoryBufferByteStream(std::unique_ptr<MemoryBuffer> Buffer)
-      : BinaryByteStream(Buffer->getBuffer()), MemBuffer(std::move(Buffer)) {}
+  MemoryBufferByteStream(std::unique_ptr<MemoryBuffer> Buffer,
+                         llvm::support::endianness Endian)
+      : BinaryByteStream(Buffer->getBuffer(), Endian),
+        MemBuffer(std::move(Buffer)) {}
 
   std::unique_ptr<MemoryBuffer> MemBuffer;
 };
@@ -89,8 +95,13 @@ public:
 class MutableBinaryByteStream : public WritableBinaryStream {
 public:
   MutableBinaryByteStream() = default;
-  MutableBinaryByteStream(MutableArrayRef<uint8_t> Data)
-      : Data(Data), ImmutableStream(Data) {}
+  MutableBinaryByteStream(MutableArrayRef<uint8_t> Data,
+                          llvm::support::endianness Endian)
+      : Data(Data), ImmutableStream(Data, Endian) {}
+
+  llvm::support::endianness getEndian() const override {
+    return ImmutableStream.getEndian();
+  }
 
   Error readBytes(uint32_t Offset, uint32_t Size,
                   ArrayRef<uint8_t> &Buffer) override {
@@ -135,9 +146,12 @@ class FileBufferByteStream : public Writ
 private:
   class StreamImpl : public MutableBinaryByteStream {
   public:
-    StreamImpl(std::unique_ptr<FileOutputBuffer> Buffer)
-        : MutableBinaryByteStream(MutableArrayRef<uint8_t>(
-              Buffer->getBufferStart(), Buffer->getBufferEnd())),
+    StreamImpl(std::unique_ptr<FileOutputBuffer> Buffer,
+               llvm::support::endianness Endian)
+        : MutableBinaryByteStream(
+              MutableArrayRef<uint8_t>(Buffer->getBufferStart(),
+                                       Buffer->getBufferEnd()),
+              Endian),
           FileBuffer(std::move(Buffer)) {}
 
     Error commit() override {
@@ -152,8 +166,13 @@ private:
   };
 
 public:
-  explicit FileBufferByteStream(std::unique_ptr<FileOutputBuffer> Buffer)
-      : Impl(std::move(Buffer)) {}
+  FileBufferByteStream(std::unique_ptr<FileOutputBuffer> Buffer,
+                       llvm::support::endianness Endian)
+      : Impl(std::move(Buffer), Endian) {}
+
+  llvm::support::endianness getEndian() const override {
+    return Impl.getEndian();
+  }
 
   Error readBytes(uint32_t Offset, uint32_t Size,
                   ArrayRef<uint8_t> &Buffer) override {
@@ -179,4 +198,4 @@ private:
 
 } // end namespace llvm
 
-#endif // LLVM_DEBUGINFO_MSF_BINARYBYTESTREAM_H
+#endif // LLVM_DEBUGINFO_MSF_BYTESTREAM_H

Modified: llvm/trunk/include/llvm/DebugInfo/MSF/BinaryItemStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/MSF/BinaryItemStream.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/MSF/BinaryItemStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/MSF/BinaryItemStream.h Mon Feb 27 18:04:07 2017
@@ -34,7 +34,10 @@ template <typename T> struct BinaryItemT
 template <typename T, typename Traits = BinaryItemTraits<T>>
 class BinaryItemStream : public BinaryStream {
 public:
-  BinaryItemStream() = default;
+  explicit BinaryItemStream(llvm::support::endianness Endian)
+      : Endian(Endian) {}
+
+  llvm::support::endianness getEndian() const override { return Endian; }
 
   Error readBytes(uint32_t Offset, uint32_t Size,
                   ArrayRef<uint8_t> &Buffer) override {
@@ -83,6 +86,7 @@ private:
     return CurrentIndex;
   }
 
+  llvm::support::endianness Endian;
   ArrayRef<T> Items;
 };
 

Modified: llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStream.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStream.h Mon Feb 27 18:04:07 2017
@@ -28,6 +28,8 @@ class BinaryStream {
 public:
   virtual ~BinaryStream() = default;
 
+  virtual llvm::support::endianness getEndian() const = 0;
+
   /// \brief Given an offset into the stream and a number of bytes, attempt to
   /// read the bytes and set the output ArrayRef to point to data owned by the
   /// stream.

Modified: llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamReader.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamReader.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamReader.h Mon Feb 27 18:04:07 2017
@@ -12,8 +12,8 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/DebugInfo/MSF/BinaryStream.h"
 #include "llvm/DebugInfo/MSF/BinaryStreamArray.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamRef.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MathExtras.h"
@@ -58,8 +58,7 @@ public:
   ///
   /// \returns a success error code if the data was successfully read, otherwise
   /// returns an appropriate error code.
-  template <typename T>
-  Error readInteger(T &Dest, llvm::support::endianness Endian) {
+  template <typename T> Error readInteger(T &Dest) {
     static_assert(std::is_integral<T>::value,
                   "Cannot call readInteger with non-integral value!");
 
@@ -68,17 +67,16 @@ public:
       return EC;
 
     Dest = llvm::support::endian::read<T, llvm::support::unaligned>(
-        Bytes.data(), Endian);
+        Bytes.data(), Stream.getEndian());
     return Error::success();
   }
 
   /// Similar to readInteger.
-  template <typename T>
-  Error readEnum(T &Dest, llvm::support::endianness Endian) {
+  template <typename T> Error readEnum(T &Dest) {
     static_assert(std::is_enum<T>::value,
                   "Cannot call readEnum with non-enum value!");
     typename std::underlying_type<T>::type N;
-    if (auto EC = readInteger(N, Endian))
+    if (auto EC = readInteger(N))
       return EC;
     Dest = static_cast<T>(N);
     return Error::success();

Modified: llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamRef.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamRef.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamRef.h Mon Feb 27 18:04:07 2017
@@ -26,6 +26,8 @@ public:
   BinaryStreamRefBase(StreamType &Stream, uint32_t Offset, uint32_t Length)
       : Stream(&Stream), ViewOffset(Offset), Length(Length) {}
 
+  llvm::support::endianness getEndian() const { return Stream->getEndian(); }
+
   uint32_t getLength() const { return Length; }
   const StreamType *getStream() const { return Stream; }
 

Modified: llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamWriter.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamWriter.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/MSF/BinaryStreamWriter.h Mon Feb 27 18:04:07 2017
@@ -47,24 +47,22 @@ public:
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  template <typename T>
-  Error writeInteger(T Value, llvm::support::endianness Endian) {
+  template <typename T> Error writeInteger(T Value) {
     static_assert(std::is_integral<T>::value,
                   "Cannot call writeInteger with non-integral value!");
     uint8_t Buffer[sizeof(T)];
-    llvm::support::endian::write<T, llvm::support::unaligned>(Buffer, Value,
-                                                              Endian);
+    llvm::support::endian::write<T, llvm::support::unaligned>(
+        Buffer, Value, Stream.getEndian());
     return writeBytes(Buffer);
   }
 
   /// Similar to writeInteger
-  template <typename T>
-  Error writeEnum(T Num, llvm::support::endianness Endian) {
+  template <typename T> Error writeEnum(T Num) {
     static_assert(std::is_enum<T>::value,
                   "Cannot call writeEnum with non-Enum type");
 
     using U = typename std::underlying_type<T>::type;
-    return writeInteger<U>(static_cast<U>(Num), Endian);
+    return writeInteger<U>(static_cast<U>(Num));
   }
 
   /// Write the the string \p Str to the underlying stream followed by a null

Modified: llvm/trunk/include/llvm/DebugInfo/MSF/MappedBlockStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/MSF/MappedBlockStream.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/MSF/MappedBlockStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/MSF/MappedBlockStream.h Mon Feb 27 18:04:07 2017
@@ -56,6 +56,10 @@ public:
   static std::unique_ptr<MappedBlockStream>
   createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData);
 
+  llvm::support::endianness getEndian() const override {
+    return llvm::support::little;
+  }
+
   Error readBytes(uint32_t Offset, uint32_t Size,
                   ArrayRef<uint8_t> &Buffer) override;
   Error readLongestContiguousChunk(uint32_t Offset,
@@ -113,6 +117,10 @@ public:
   static std::unique_ptr<WritableMappedBlockStream>
   createFpmStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData);
 
+  llvm::support::endianness getEndian() const override {
+    return llvm::support::little;
+  }
+
   Error readBytes(uint32_t Offset, uint32_t Size,
                   ArrayRef<uint8_t> &Buffer) override;
   Error readLongestContiguousChunk(uint32_t Offset,

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h Mon Feb 27 18:04:07 2017
@@ -12,6 +12,8 @@
 
 #include "llvm/DebugInfo/CodeView/ModuleSubstream.h"
 #include "llvm/DebugInfo/MSF/BinaryStreamArray.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamArray.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamRef.h"
 #include "llvm/DebugInfo/MSF/BinaryStreamRef.h"
 #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
 #include "llvm/DebugInfo/PDB/Native/ModInfo.h"

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h Mon Feb 27 18:04:07 2017
@@ -19,7 +19,7 @@
 #include "llvm/DebugInfo/PDB/PDBTypes.h"
 
 namespace llvm {
-class BinaryStreamWriter;
+class WritableBinaryStreamRef;
 
 namespace msf {
 class MSFBuilder;

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h Mon Feb 27 18:04:07 2017
@@ -11,8 +11,7 @@
 #define LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H
 
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/DebugInfo/MSF/BinaryStream.h"
-#include "llvm/DebugInfo/MSF/BinaryStreamArray.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamRef.h"
 #include "llvm/DebugInfo/MSF/IMSFFile.h"
 #include "llvm/DebugInfo/MSF/MSFCommon.h"
 #include "llvm/Support/Allocator.h"
@@ -24,6 +23,8 @@
 
 namespace llvm {
 
+class BinaryStream;
+
 namespace msf {
 class MappedBlockStream;
 }

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h Mon Feb 27 18:04:07 2017
@@ -16,7 +16,6 @@
 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
 #include "llvm/DebugInfo/PDB/PDBTypes.h"
-
 #include "llvm/Support/Error.h"
 
 namespace llvm {

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h Mon Feb 27 18:04:07 2017
@@ -14,6 +14,7 @@
 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
 #include "llvm/DebugInfo/MSF/BinaryByteStream.h"
 #include "llvm/DebugInfo/MSF/BinaryItemStream.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamRef.h"
 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Error.h"
@@ -22,12 +23,7 @@
 
 namespace llvm {
 class BinaryByteStream;
-class BinaryStreamRef;
-class WritableBinaryStream;
-
-namespace codeview {
-class TypeRecord;
-}
+class WritableBinaryStreamRef;
 
 template <> struct BinaryItemTraits<llvm::codeview::CVType> {
   static size_t length(const codeview::CVType &Item) { return Item.length(); }
@@ -36,6 +32,9 @@ template <> struct BinaryItemTraits<llvm
   }
 };
 
+namespace codeview {
+class TypeRecord;
+}
 namespace msf {
 class MSFBuilder;
 struct MSFLayout;

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Mon Feb 27 18:04:07 2017
@@ -494,7 +494,7 @@ void CodeViewDebug::emitTypeInformation(
       // comments. The MSVC linker doesn't do much type record validation,
       // so the first link of an invalid type record can succeed while
       // subsequent links will fail with LNK1285.
-      BinaryByteStream Stream(Record);
+      BinaryByteStream Stream(Record, llvm::support::little);
       CVTypeArray Types;
       BinaryStreamReader Reader(Stream);
       Error E = Reader.readArray(Types, Reader.getLength());

Modified: llvm/trunk/lib/DebugInfo/CodeView/CVTypeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CVTypeDumper.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CVTypeDumper.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/CVTypeDumper.cpp Mon Feb 27 18:04:07 2017
@@ -56,7 +56,7 @@ Error CVTypeDumper::dump(const CVTypeArr
 }
 
 Error CVTypeDumper::dump(ArrayRef<uint8_t> Data, TypeVisitorCallbacks &Dumper) {
-  BinaryByteStream Stream(Data);
+  BinaryByteStream Stream(Data, llvm::support::little);
   CVTypeArray Types;
   BinaryStreamReader Reader(Stream);
   if (auto EC = Reader.readArray(Types, Reader.getLength()))

Modified: llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp Mon Feb 27 18:04:07 2017
@@ -182,7 +182,7 @@ Error CVTypeVisitor::visitFieldListMembe
 
   TypeLeafKind Leaf;
   while (!Reader.empty()) {
-    if (auto EC = Reader.readEnum(Leaf, llvm::support::little))
+    if (auto EC = Reader.readEnum(Leaf))
       return EC;
 
     CVMemberRecord Record;
@@ -195,7 +195,7 @@ Error CVTypeVisitor::visitFieldListMembe
 }
 
 Error CVTypeVisitor::visitFieldListMemberStream(ArrayRef<uint8_t> Data) {
-  BinaryByteStream S(Data);
+  BinaryByteStream S(Data, llvm::support::little);
   BinaryStreamReader SR(S);
   return visitFieldListMemberStream(SR);
 }

Modified: llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp Mon Feb 27 18:04:07 2017
@@ -87,14 +87,13 @@ Error CodeViewRecordIO::mapByteVectorTai
 
 Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) {
   if (isWriting()) {
-    if (auto EC =
-            Writer->writeInteger(TypeInd.getIndex(), llvm::support::little))
+    if (auto EC = Writer->writeInteger(TypeInd.getIndex()))
       return EC;
     return Error::success();
   }
 
   uint32_t I;
-  if (auto EC = Reader->readInteger(I, llvm::support::little))
+  if (auto EC = Reader->readInteger(I))
     return EC;
   TypeInd.setIndex(I);
   return Error::success();
@@ -177,7 +176,7 @@ Error CodeViewRecordIO::mapStringZVector
       if (auto EC = mapStringZ(V))
         return EC;
     }
-    if (auto EC = Writer->writeInteger<uint8_t>(0, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint8_t>(0))
       return EC;
   } else {
     StringRef S;
@@ -195,28 +194,24 @@ Error CodeViewRecordIO::mapStringZVector
 Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) {
   assert(Value < 0 && "Encoded integer is not signed!");
   if (Value >= std::numeric_limits<int8_t>::min()) {
-    if (auto EC =
-            Writer->writeInteger<uint16_t>(LF_CHAR, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint16_t>(LF_CHAR))
       return EC;
-    if (auto EC = Writer->writeInteger<int8_t>(Value, llvm::support::little))
+    if (auto EC = Writer->writeInteger<int8_t>(Value))
       return EC;
   } else if (Value >= std::numeric_limits<int16_t>::min()) {
-    if (auto EC =
-            Writer->writeInteger<uint16_t>(LF_SHORT, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint16_t>(LF_SHORT))
       return EC;
-    if (auto EC = Writer->writeInteger<int16_t>(Value, llvm::support::little))
+    if (auto EC = Writer->writeInteger<int16_t>(Value))
       return EC;
   } else if (Value >= std::numeric_limits<int32_t>::min()) {
-    if (auto EC =
-            Writer->writeInteger<uint16_t>(LF_LONG, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint16_t>(LF_LONG))
       return EC;
-    if (auto EC = Writer->writeInteger<int32_t>(Value, llvm::support::little))
+    if (auto EC = Writer->writeInteger<int32_t>(Value))
       return EC;
   } else {
-    if (auto EC =
-            Writer->writeInteger<uint16_t>(LF_QUADWORD, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint16_t>(LF_QUADWORD))
       return EC;
-    if (auto EC = Writer->writeInteger(Value, llvm::support::little))
+    if (auto EC = Writer->writeInteger(Value))
       return EC;
   }
   return Error::success();
@@ -224,25 +219,22 @@ Error CodeViewRecordIO::writeEncodedSign
 
 Error CodeViewRecordIO::writeEncodedUnsignedInteger(const uint64_t &Value) {
   if (Value < LF_NUMERIC) {
-    if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint16_t>(Value))
       return EC;
   } else if (Value <= std::numeric_limits<uint16_t>::max()) {
-    if (auto EC =
-            Writer->writeInteger<uint16_t>(LF_USHORT, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint16_t>(LF_USHORT))
       return EC;
-    if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint16_t>(Value))
       return EC;
   } else if (Value <= std::numeric_limits<uint32_t>::max()) {
-    if (auto EC =
-            Writer->writeInteger<uint16_t>(LF_ULONG, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint16_t>(LF_ULONG))
       return EC;
-    if (auto EC = Writer->writeInteger<uint32_t>(Value, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint32_t>(Value))
       return EC;
   } else {
-    if (auto EC =
-            Writer->writeInteger<uint16_t>(LF_UQUADWORD, llvm::support::little))
+    if (auto EC = Writer->writeInteger<uint16_t>(LF_UQUADWORD))
       return EC;
-    if (auto EC = Writer->writeInteger(Value, llvm::support::little))
+    if (auto EC = Writer->writeInteger(Value))
       return EC;
   }
 

Modified: llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp Mon Feb 27 18:04:07 2017
@@ -37,7 +37,7 @@ Error llvm::codeview::consume(BinaryStre
   // Used to avoid overload ambiguity on APInt construtor.
   bool FalseVal = false;
   uint16_t Short;
-  if (auto EC = Reader.readInteger(Short, llvm::support::little))
+  if (auto EC = Reader.readInteger(Short))
     return EC;
 
   if (Short < LF_NUMERIC) {
@@ -49,49 +49,49 @@ Error llvm::codeview::consume(BinaryStre
   switch (Short) {
   case LF_CHAR: {
     int8_t N;
-    if (auto EC = Reader.readInteger(N, llvm::support::little))
+    if (auto EC = Reader.readInteger(N))
       return EC;
     Num = APSInt(APInt(8, N, true), false);
     return Error::success();
   }
   case LF_SHORT: {
     int16_t N;
-    if (auto EC = Reader.readInteger(N, llvm::support::little))
+    if (auto EC = Reader.readInteger(N))
       return EC;
     Num = APSInt(APInt(16, N, true), false);
     return Error::success();
   }
   case LF_USHORT: {
     uint16_t N;
-    if (auto EC = Reader.readInteger(N, llvm::support::little))
+    if (auto EC = Reader.readInteger(N))
       return EC;
     Num = APSInt(APInt(16, N, false), true);
     return Error::success();
   }
   case LF_LONG: {
     int32_t N;
-    if (auto EC = Reader.readInteger(N, llvm::support::little))
+    if (auto EC = Reader.readInteger(N))
       return EC;
     Num = APSInt(APInt(32, N, true), false);
     return Error::success();
   }
   case LF_ULONG: {
     uint32_t N;
-    if (auto EC = Reader.readInteger(N, llvm::support::little))
+    if (auto EC = Reader.readInteger(N))
       return EC;
     Num = APSInt(APInt(32, N, FalseVal), true);
     return Error::success();
   }
   case LF_QUADWORD: {
     int64_t N;
-    if (auto EC = Reader.readInteger(N, llvm::support::little))
+    if (auto EC = Reader.readInteger(N))
       return EC;
     Num = APSInt(APInt(64, N, true), false);
     return Error::success();
   }
   case LF_UQUADWORD: {
     uint64_t N;
-    if (auto EC = Reader.readInteger(N, llvm::support::little))
+    if (auto EC = Reader.readInteger(N))
       return EC;
     Num = APSInt(APInt(64, N, false), true);
     return Error::success();
@@ -103,7 +103,7 @@ Error llvm::codeview::consume(BinaryStre
 
 Error llvm::codeview::consume(StringRef &Data, APSInt &Num) {
   ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end());
-  BinaryByteStream S(Bytes);
+  BinaryByteStream S(Bytes, llvm::support::little);
   BinaryStreamReader SR(S);
   auto EC = consume(SR, Num);
   Data = Data.take_back(SR.bytesRemaining());
@@ -124,12 +124,12 @@ Error llvm::codeview::consume_numeric(Bi
 }
 
 Error llvm::codeview::consume(BinaryStreamReader &Reader, uint32_t &Item) {
-  return Reader.readInteger(Item, llvm::support::little);
+  return Reader.readInteger(Item);
 }
 
 Error llvm::codeview::consume(StringRef &Data, uint32_t &Item) {
   ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end());
-  BinaryByteStream S(Bytes);
+  BinaryByteStream S(Bytes, llvm::support::little);
   BinaryStreamReader SR(S);
   auto EC = consume(SR, Item);
   Data = Data.take_back(SR.bytesRemaining());
@@ -137,7 +137,7 @@ Error llvm::codeview::consume(StringRef
 }
 
 Error llvm::codeview::consume(BinaryStreamReader &Reader, int32_t &Item) {
-  return Reader.readInteger(Item, llvm::support::little);
+  return Reader.readInteger(Item);
 }
 
 Error llvm::codeview::consume(BinaryStreamReader &Reader, StringRef &Item) {

Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeSerializer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeSerializer.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeSerializer.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeSerializer.cpp Mon Feb 27 18:04:07 2017
@@ -76,7 +76,7 @@ TypeSerializer::addPadding(MutableArrayR
   int N = PaddingBytes;
   while (PaddingBytes > 0) {
     uint8_t Pad = static_cast<uint8_t>(LF_PAD0 + PaddingBytes);
-    if (auto EC = Writer.writeInteger(Pad, llvm::support::little))
+    if (auto EC = Writer.writeInteger(Pad))
       return std::move(EC);
     --PaddingBytes;
   }
@@ -85,7 +85,8 @@ TypeSerializer::addPadding(MutableArrayR
 
 TypeSerializer::TypeSerializer(BumpPtrAllocator &Storage)
     : RecordStorage(Storage), LastTypeIndex(),
-      RecordBuffer(MaxRecordLength * 2), Stream(RecordBuffer), Writer(Stream),
+      RecordBuffer(MaxRecordLength * 2),
+      Stream(RecordBuffer, llvm::support::little), Writer(Stream),
       Mapping(Writer) {
   // RecordBuffer needs to be able to hold enough data so that if we are 1
   // byte short of MaxRecordLen, and then we try to write MaxRecordLen bytes,
@@ -203,15 +204,15 @@ Error TypeSerializer::visitMemberEnd(CVM
 
     uint8_t *SegmentBytes = RecordStorage.Allocate<uint8_t>(LengthWithSize);
     auto SavedSegment = MutableArrayRef<uint8_t>(SegmentBytes, LengthWithSize);
-    MutableBinaryByteStream CS(SavedSegment);
+    MutableBinaryByteStream CS(SavedSegment, llvm::support::little);
     BinaryStreamWriter CW(CS);
     if (auto EC = CW.writeBytes(CopyData))
       return EC;
-    if (auto EC = CW.writeEnum(TypeLeafKind::LF_INDEX, llvm::support::little))
+    if (auto EC = CW.writeEnum(TypeLeafKind::LF_INDEX))
       return EC;
-    if (auto EC = CW.writeInteger<uint16_t>(0, llvm::support::little))
+    if (auto EC = CW.writeInteger<uint16_t>(0))
       return EC;
-    if (auto EC = CW.writeInteger<uint32_t>(0xB0C0B0C0, llvm::support::little))
+    if (auto EC = CW.writeInteger<uint32_t>(0xB0C0B0C0))
       return EC;
     FieldListSegments.push_back(SavedSegment);
 

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp Mon Feb 27 18:04:07 2017
@@ -236,7 +236,7 @@ Error DbiStream::initializeSectionContri
     return Error::success();
 
   BinaryStreamReader SCReader(SecContrSubstream);
-  if (auto EC = SCReader.readEnum(SectionContribVersion, llvm::support::little))
+  if (auto EC = SCReader.readEnum(SectionContribVersion))
     return EC;
 
   if (SectionContribVersion == DbiSecContribVer60)

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp Mon Feb 27 18:04:07 2017
@@ -153,7 +153,8 @@ Error DbiStreamBuilder::generateModiSubs
   uint32_t Size = calculateModiSubstreamSize();
   auto Data = Allocator.Allocate<uint8_t>(Size);
 
-  ModInfoBuffer = MutableBinaryByteStream(MutableArrayRef<uint8_t>(Data, Size));
+  ModInfoBuffer = MutableBinaryByteStream(MutableArrayRef<uint8_t>(Data, Size),
+                                          llvm::support::little);
 
   BinaryStreamWriter ModiWriter(ModInfoBuffer);
   for (const auto &M : ModuleInfoList) {
@@ -179,8 +180,8 @@ Error DbiStreamBuilder::generateFileInfo
   auto Data = Allocator.Allocate<uint8_t>(Size);
   uint32_t NamesOffset = Size - NameSize;
 
-  FileInfoBuffer =
-      MutableBinaryByteStream(MutableArrayRef<uint8_t>(Data, Size));
+  FileInfoBuffer = MutableBinaryByteStream(MutableArrayRef<uint8_t>(Data, Size),
+                                           llvm::support::little);
 
   WritableBinaryStreamRef MetadataBuffer =
       WritableBinaryStreamRef(FileInfoBuffer).keep_front(NamesOffset);
@@ -188,21 +189,17 @@ Error DbiStreamBuilder::generateFileInfo
 
   uint16_t ModiCount = std::min<uint32_t>(UINT16_MAX, ModuleInfos.size());
   uint16_t FileCount = std::min<uint32_t>(UINT16_MAX, SourceFileNames.size());
-  if (auto EC = MetadataWriter.writeInteger(
-          ModiCount, llvm::support::little)) // NumModules
+  if (auto EC = MetadataWriter.writeInteger(ModiCount)) // NumModules
     return EC;
-  if (auto EC = MetadataWriter.writeInteger(
-          FileCount, llvm::support::little)) // NumSourceFiles
+  if (auto EC = MetadataWriter.writeInteger(FileCount)) // NumSourceFiles
     return EC;
   for (uint16_t I = 0; I < ModiCount; ++I) {
-    if (auto EC = MetadataWriter.writeInteger(
-            I, llvm::support::little)) // Mod Indices
+    if (auto EC = MetadataWriter.writeInteger(I)) // Mod Indices
       return EC;
   }
   for (const auto MI : ModuleInfoList) {
     FileCount = static_cast<uint16_t>(MI->SourceFiles.size());
-    if (auto EC = MetadataWriter.writeInteger(
-            FileCount, llvm::support::little)) // Mod File Counts
+    if (auto EC = MetadataWriter.writeInteger(FileCount)) // Mod File Counts
       return EC;
   }
 
@@ -224,8 +221,7 @@ Error DbiStreamBuilder::generateFileInfo
       if (Result == SourceFileNames.end())
         return make_error<RawError>(raw_error_code::no_entry,
                                     "The source file was not found.");
-      if (auto EC = MetadataWriter.writeInteger(Result->second,
-                                                llvm::support::little))
+      if (auto EC = MetadataWriter.writeInteger(Result->second))
         return EC;
     }
   }
@@ -379,7 +375,7 @@ Error DbiStreamBuilder::commit(const msf
     return EC;
 
   if (!SectionContribs.empty()) {
-    if (auto EC = Writer.writeEnum(DbiSecContribVer60, llvm::support::little))
+    if (auto EC = Writer.writeEnum(DbiSecContribVer60))
       return EC;
     if (auto EC = Writer.writeArray(SectionContribs))
       return EC;
@@ -398,16 +394,15 @@ Error DbiStreamBuilder::commit(const msf
     return EC;
 
   for (auto &Stream : DbgStreams)
-    if (auto EC =
-            Writer.writeInteger(Stream.StreamNumber, llvm::support::little))
+    if (auto EC = Writer.writeInteger(Stream.StreamNumber))
       return EC;
 
   for (auto &Stream : DbgStreams) {
     if (Stream.StreamNumber == kInvalidStreamIndex)
       continue;
-    auto WritableBinaryStream = WritableMappedBlockStream::createIndexedStream(
+    auto WritableStream = WritableMappedBlockStream::createIndexedStream(
         Layout, Buffer, Stream.StreamNumber);
-    BinaryStreamWriter DbgStreamWriter(*WritableBinaryStream);
+    BinaryStreamWriter DbgStreamWriter(*WritableStream);
     if (auto EC = DbgStreamWriter.writeArray(Stream.Data))
       return EC;
   }

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/HashTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/HashTable.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/HashTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/HashTable.cpp Mon Feb 27 18:04:07 2017
@@ -48,9 +48,9 @@ Error HashTable::load(BinaryStreamReader
                                 "Present bit vector interesects deleted!");
 
   for (uint32_t P : Present) {
-    if (auto EC = Stream.readInteger(Buckets[P].first, llvm::support::little))
+    if (auto EC = Stream.readInteger(Buckets[P].first))
       return EC;
-    if (auto EC = Stream.readInteger(Buckets[P].second, llvm::support::little))
+    if (auto EC = Stream.readInteger(Buckets[P].second))
       return EC;
   }
 
@@ -91,9 +91,9 @@ Error HashTable::commit(BinaryStreamWrit
     return EC;
 
   for (const auto &Entry : *this) {
-    if (auto EC = Writer.writeInteger(Entry.first, llvm::support::little))
+    if (auto EC = Writer.writeInteger(Entry.first))
       return EC;
-    if (auto EC = Writer.writeInteger(Entry.second, llvm::support::little))
+    if (auto EC = Writer.writeInteger(Entry.second))
       return EC;
   }
   return Error::success();
@@ -212,7 +212,7 @@ void HashTable::grow() {
 Error HashTable::readSparseBitVector(BinaryStreamReader &Stream,
                                      SparseBitVector<> &V) {
   uint32_t NumWords;
-  if (auto EC = Stream.readInteger(NumWords, llvm::support::little))
+  if (auto EC = Stream.readInteger(NumWords))
     return joinErrors(
         std::move(EC),
         make_error<RawError>(raw_error_code::corrupt_file,
@@ -220,7 +220,7 @@ Error HashTable::readSparseBitVector(Bin
 
   for (uint32_t I = 0; I != NumWords; ++I) {
     uint32_t Word;
-    if (auto EC = Stream.readInteger(Word, llvm::support::little))
+    if (auto EC = Stream.readInteger(Word))
       return joinErrors(std::move(EC),
                         make_error<RawError>(raw_error_code::corrupt_file,
                                              "Expected hash table word"));
@@ -235,7 +235,7 @@ Error HashTable::writeSparseBitVector(Bi
                                       SparseBitVector<> &Vec) {
   int ReqBits = Vec.find_last() + 1;
   uint32_t NumWords = alignTo(ReqBits, sizeof(uint32_t)) / sizeof(uint32_t);
-  if (auto EC = Writer.writeInteger(NumWords, llvm::support::little))
+  if (auto EC = Writer.writeInteger(NumWords))
     return joinErrors(
         std::move(EC),
         make_error<RawError>(raw_error_code::corrupt_file,
@@ -248,7 +248,7 @@ Error HashTable::writeSparseBitVector(Bi
       if (Vec.test(Idx))
         Word |= (1 << WordIdx);
     }
-    if (auto EC = Writer.writeInteger(Word, llvm::support::little))
+    if (auto EC = Writer.writeInteger(Word))
       return joinErrors(std::move(EC), make_error<RawError>(
                                            raw_error_code::corrupt_file,
                                            "Could not write linear map word"));

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/ModStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/ModStream.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/ModStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/ModStream.cpp Mon Feb 27 18:04:07 2017
@@ -43,7 +43,7 @@ Error ModStream::reload() {
 
   BinaryStreamRef S;
 
-  if (auto EC = Reader.readInteger(Signature, llvm::support::little))
+  if (auto EC = Reader.readInteger(Signature))
     return EC;
   if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4))
     return EC;
@@ -58,7 +58,7 @@ Error ModStream::reload() {
     return EC;
 
   uint32_t GlobalRefsSize;
-  if (auto EC = Reader.readInteger(GlobalRefsSize, llvm::support::little))
+  if (auto EC = Reader.readInteger(GlobalRefsSize))
     return EC;
   if (auto EC = Reader.readStreamRef(GlobalRefsSubstream, GlobalRefsSize))
     return EC;

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp Mon Feb 27 18:04:07 2017
@@ -31,7 +31,7 @@ Error NamedStreamMap::load(BinaryStreamR
   FinalizedInfo.reset();
 
   uint32_t StringBufferSize;
-  if (auto EC = Stream.readInteger(StringBufferSize, llvm::support::little))
+  if (auto EC = Stream.readInteger(StringBufferSize))
     return joinErrors(std::move(EC),
                       make_error<RawError>(raw_error_code::corrupt_file,
                                            "Expected string buffer size"));
@@ -70,8 +70,7 @@ Error NamedStreamMap::commit(BinaryStrea
   assert(FinalizedInfo.hasValue());
 
   // The first field is the number of bytes of string data.
-  if (auto EC = Writer.writeInteger(FinalizedInfo->StringDataBytes,
-                                    llvm::support::little))
+  if (auto EC = Writer.writeInteger(FinalizedInfo->StringDataBytes))
     return EC;
 
   // Now all of the string data itself.

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp Mon Feb 27 18:04:07 2017
@@ -45,7 +45,8 @@ Error NativeSession::createFromPdb(Strin
     return make_error<GenericError>(generic_error_code::invalid_path);
 
   std::unique_ptr<MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
-  auto Stream = llvm::make_unique<MemoryBufferByteStream>(std::move(Buffer));
+  auto Stream = llvm::make_unique<MemoryBufferByteStream>(
+      std::move(Buffer), llvm::support::little);
 
   auto Allocator = llvm::make_unique<BumpPtrAllocator>();
   auto File = llvm::make_unique<PDBFile>(Path, std::move(Stream), *Allocator);

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp Mon Feb 27 18:04:07 2017
@@ -186,7 +186,7 @@ Error PDBFile::parseStreamData() {
   // been parsed, we can avoid this and reuse MappedBlockStream.
   auto DS = MappedBlockStream::createDirectoryStream(ContainerLayout, *Buffer);
   BinaryStreamReader Reader(*DS);
-  if (auto EC = Reader.readInteger(NumStreams, llvm::support::little))
+  if (auto EC = Reader.readInteger(NumStreams))
     return EC;
 
   if (auto EC = Reader.readArray(ContainerLayout.StreamSizes, NumStreams))

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp Mon Feb 27 18:04:07 2017
@@ -118,7 +118,8 @@ Error PDBFileBuilder::commit(StringRef F
   if (OutFileOrError.getError())
     return llvm::make_error<pdb::GenericError>(generic_error_code::invalid_path,
                                                Filename);
-  FileBufferByteStream Buffer(std::move(*OutFileOrError));
+  FileBufferByteStream Buffer(std::move(*OutFileOrError),
+                              llvm::support::little);
   BinaryStreamWriter Writer(Buffer);
 
   if (auto EC = Writer.writeObject(*Layout.SB))
@@ -132,8 +133,7 @@ Error PDBFileBuilder::commit(StringRef F
   auto DirStream =
       WritableMappedBlockStream::createDirectoryStream(Layout, Buffer);
   BinaryStreamWriter DW(*DirStream);
-  if (auto EC = DW.writeInteger<uint32_t>(Layout.StreamSizes.size(),
-                                          llvm::support::little))
+  if (auto EC = DW.writeInteger<uint32_t>(Layout.StreamSizes.size()))
     return EC;
 
   if (auto EC = DW.writeArray(Layout.StreamSizes))

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp Mon Feb 27 18:04:07 2017
@@ -54,7 +54,7 @@ Error StringTable::load(BinaryStreamRead
     return make_error<RawError>(raw_error_code::corrupt_file,
                                 "Missing name count");
 
-  if (auto EC = Stream.readInteger(NameCount, llvm::support::little))
+  if (auto EC = Stream.readInteger(NameCount))
     return EC;
   return Error::success();
 }

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp Mon Feb 27 18:04:07 2017
@@ -74,7 +74,7 @@ Error StringTableBuilder::commit(BinaryS
 
   // Write a hash table.
   uint32_t BucketCount = computeBucketCount(Strings.size());
-  if (auto EC = Writer.writeInteger(BucketCount, llvm::support::little))
+  if (auto EC = Writer.writeInteger(BucketCount))
     return EC;
   std::vector<ulittle32_t> Buckets(BucketCount);
 
@@ -96,8 +96,7 @@ Error StringTableBuilder::commit(BinaryS
 
   if (auto EC = Writer.writeArray(ArrayRef<ulittle32_t>(Buckets)))
     return EC;
-  if (auto EC = Writer.writeInteger(static_cast<uint32_t>(Strings.size()),
-                                    llvm::support::little))
+  if (auto EC = Writer.writeInteger(static_cast<uint32_t>(Strings.size())))
     return EC;
   return Error::success();
 }

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/SymbolStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/SymbolStream.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/SymbolStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/SymbolStream.cpp Mon Feb 27 18:04:07 2017
@@ -16,7 +16,6 @@
 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Native/RawError.h"
-
 #include "llvm/Support/Endian.h"
 
 using namespace llvm;

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp Mon Feb 27 18:04:07 2017
@@ -34,7 +34,8 @@ using namespace llvm::pdb;
 using namespace llvm::support;
 
 TpiStreamBuilder::TpiStreamBuilder(MSFBuilder &Msf, uint32_t StreamIdx)
-    : Msf(Msf), Allocator(Msf.getAllocator()), Header(nullptr), Idx(StreamIdx) {
+    : Msf(Msf), Allocator(Msf.getAllocator()),
+      TypeRecordStream(llvm::support::little), Header(nullptr), Idx(StreamIdx) {
 }
 
 TpiStreamBuilder::~TpiStreamBuilder() = default;
@@ -113,7 +114,8 @@ Error TpiStreamBuilder::finalizeMsfLayou
   }
   ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(HashBuffer.data()),
                           HashBufferSize);
-  HashValueStream = llvm::make_unique<BinaryByteStream>(Bytes);
+  HashValueStream =
+      llvm::make_unique<BinaryByteStream>(Bytes, llvm::support::little);
   return Error::success();
 }
 

Modified: llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp Mon Feb 27 18:04:07 2017
@@ -573,7 +573,7 @@ struct MappingContextTraits<pdb::yaml::P
     assert(IO.outputting());
     codeview::TypeVisitorCallbackPipeline Pipeline;
 
-    BinaryByteStream Data(Obj.Record.Data);
+    BinaryByteStream Data(Obj.Record.Data, llvm::support::little);
     BinaryStreamReader FieldReader(Data);
     codeview::FieldListDeserializer Deserializer(FieldReader);
 

Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Mon Feb 27 18:04:07 2017
@@ -840,7 +840,7 @@ void COFFDumper::printCodeViewSymbolSect
     }
     case ModuleSubstreamKind::FrameData: {
       // First four bytes is a relocation against the function.
-      BinaryByteStream S(Contents);
+      BinaryByteStream S(Contents, llvm::support::little);
       BinaryStreamReader SR(S);
       const uint32_t *CodePtr;
       error(SR.readObject(CodePtr));
@@ -965,7 +965,7 @@ void COFFDumper::printCodeViewSymbolsSub
 
   CVSymbolDumper CVSD(W, TypeDB, std::move(CODD),
                       opts::CodeViewSubsectionBytes);
-  BinaryByteStream Stream(BinaryData);
+  BinaryByteStream Stream(BinaryData, llvm::support::little);
   CVSymbolArray Symbols;
   BinaryStreamReader Reader(Stream);
   if (auto EC = Reader.readArray(Symbols, Reader.getLength())) {
@@ -982,7 +982,7 @@ void COFFDumper::printCodeViewSymbolsSub
 }
 
 void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
-  BinaryByteStream S(Subsection);
+  BinaryByteStream S(Subsection, llvm::support::little);
   BinaryStreamReader SR(S);
   while (!SR.empty()) {
     DictScope S(W, "FileChecksum");
@@ -1011,10 +1011,10 @@ void COFFDumper::printCodeViewFileChecks
 }
 
 void COFFDumper::printCodeViewInlineeLines(StringRef Subsection) {
-  BinaryByteStream S(Subsection);
+  BinaryByteStream S(Subsection, llvm::support::little);
   BinaryStreamReader SR(S);
   uint32_t Signature;
-  error(SR.readInteger(Signature, llvm::support::little));
+  error(SR.readInteger(Signature));
   bool HasExtraFiles = Signature == unsigned(InlineeLinesSignature::ExtraFiles);
 
   while (!SR.empty()) {
@@ -1027,12 +1027,12 @@ void COFFDumper::printCodeViewInlineeLin
 
     if (HasExtraFiles) {
       uint32_t ExtraFileCount;
-      error(SR.readInteger(ExtraFileCount, llvm::support::little));
+      error(SR.readInteger(ExtraFileCount));
       W.printNumber("ExtraFileCount", ExtraFileCount);
       ListScope ExtraFiles(W, "ExtraFiles");
       for (unsigned I = 0; I < ExtraFileCount; ++I) {
         uint32_t FileID;
-        error(SR.readInteger(FileID, llvm::support::little));
+        error(SR.readInteger(FileID));
         printFileNameForOffset("FileID", FileID);
       }
     }
@@ -1077,7 +1077,7 @@ void COFFDumper::mergeCodeViewTypes(Type
         error(object_error::parse_failed);
       ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(Data.data()),
                               Data.size());
-      BinaryByteStream Stream(Bytes);
+      BinaryByteStream Stream(Bytes, llvm::support::little);
       CVTypeArray Types;
       BinaryStreamReader Reader(Stream);
       if (auto EC = Reader.readArray(Types, Reader.getLength())) {

Modified: llvm/trunk/unittests/DebugInfo/PDB/HashTableTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/HashTableTest.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/HashTableTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/HashTableTest.cpp Mon Feb 27 18:04:07 2017
@@ -19,6 +19,7 @@
 
 using namespace llvm;
 using namespace llvm::pdb;
+using namespace llvm::support;
 
 namespace {
 class HashTableInternals : public HashTable {
@@ -147,7 +148,7 @@ TEST(HashTableTest, Serialization) {
   }
 
   std::vector<uint8_t> Buffer(Table.calculateSerializedLength());
-  MutableBinaryByteStream Stream(Buffer);
+  MutableBinaryByteStream Stream(Buffer, little);
   BinaryStreamWriter Writer(Stream);
   EXPECT_NO_ERROR(Table.commit(Writer));
   // We should have written precisely the number of bytes we calculated earlier.

Modified: llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp Mon Feb 27 18:04:07 2017
@@ -23,6 +23,7 @@
 
 using namespace llvm;
 using namespace llvm::msf;
+using namespace llvm::support;
 
 namespace {
 
@@ -37,6 +38,8 @@ public:
   uint32_t block_size() const { return 1; }
   uint32_t block_count() const { return Blocks.size(); }
 
+  endianness getEndian() const override { return little; }
+
   Error readBytes(uint32_t Offset, uint32_t Size,
                   ArrayRef<uint8_t> &Buffer) override {
     if (Offset + Size > Data.size())
@@ -326,8 +329,8 @@ TEST(MappedBlockStreamTest, TestWriteThe
 
   BinaryStreamReader Reader(*S);
   BinaryStreamWriter Writer(*S);
-  EXPECT_NO_ERROR(Writer.writeInteger(u16[0], llvm::support::little));
-  EXPECT_NO_ERROR(Reader.readInteger(u16[1], llvm::support::little));
+  EXPECT_NO_ERROR(Writer.writeInteger(u16[0]));
+  EXPECT_NO_ERROR(Reader.readInteger(u16[1]));
   EXPECT_EQ(u16[0], u16[1]);
   EXPECT_EQ(std::vector<uint8_t>({0, 0x7A, 0xEC, 0, 0, 0, 0, 0, 0, 0}),
             DataBytes);
@@ -335,8 +338,8 @@ TEST(MappedBlockStreamTest, TestWriteThe
   Reader.setOffset(0);
   Writer.setOffset(0);
   ::memset(DataBytes.data(), 0, 10);
-  EXPECT_NO_ERROR(Writer.writeInteger(u32[0], llvm::support::little));
-  EXPECT_NO_ERROR(Reader.readInteger(u32[1], llvm::support::little));
+  EXPECT_NO_ERROR(Writer.writeInteger(u32[0]));
+  EXPECT_NO_ERROR(Reader.readInteger(u32[1]));
   EXPECT_EQ(u32[0], u32[1]);
   EXPECT_EQ(std::vector<uint8_t>({0x17, 0x5C, 0x50, 0, 0, 0, 0x35, 0, 0, 0}),
             DataBytes);
@@ -344,8 +347,8 @@ TEST(MappedBlockStreamTest, TestWriteThe
   Reader.setOffset(0);
   Writer.setOffset(0);
   ::memset(DataBytes.data(), 0, 10);
-  EXPECT_NO_ERROR(Writer.writeEnum(Enum[0], llvm::support::little));
-  EXPECT_NO_ERROR(Reader.readEnum(Enum[1], llvm::support::little));
+  EXPECT_NO_ERROR(Writer.writeEnum(Enum[0]));
+  EXPECT_NO_ERROR(Reader.readEnum(Enum[1]));
   EXPECT_EQ(Enum[0], Enum[1]);
   EXPECT_EQ(std::vector<uint8_t>({0x2C, 0x60, 0x4A, 0, 0, 0, 0, 0, 0, 0}),
             DataBytes);
@@ -400,7 +403,7 @@ TEST(MappedBlockStreamTest, TestWriteCon
       F.block_size(), F.block_count(), F.layout(), F);
 
   // First write "Test Str" into the source stream.
-  MutableBinaryByteStream SourceStream(SrcData);
+  MutableBinaryByteStream SourceStream(SrcData, little);
   BinaryStreamWriter SourceWriter(SourceStream);
   EXPECT_NO_ERROR(SourceWriter.writeCString("Test Str"));
   EXPECT_EQ(SrcDataBytes, std::vector<uint8_t>(

Modified: llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp?rev=296415&r1=296414&r2=296415&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp Mon Feb 27 18:04:07 2017
@@ -19,6 +19,7 @@
 
 using namespace llvm;
 using namespace llvm::pdb;
+using namespace llvm::support;
 
 namespace {
 class StringTableBuilderTest : public ::testing::Test {};
@@ -33,12 +34,12 @@ TEST_F(StringTableBuilderTest, Simple) {
   EXPECT_EQ(9U, Builder.insert("baz"));
 
   std::vector<uint8_t> Buffer(Builder.finalize());
-  MutableBinaryByteStream OutStream(Buffer);
+  MutableBinaryByteStream OutStream(Buffer, little);
   BinaryStreamWriter Writer(OutStream);
   EXPECT_NO_ERROR(Builder.commit(Writer));
 
   // Reads the contents back.
-  BinaryByteStream InStream(Buffer);
+  BinaryByteStream InStream(Buffer, little);
   BinaryStreamReader Reader(InStream);
   StringTable Table;
   EXPECT_NO_ERROR(Table.load(Reader));




More information about the llvm-commits mailing list