]> granicus.if.org Git - llvm/commitdiff
[PDB] Make streams carry their own endianness.
authorZachary Turner <zturner@google.com>
Tue, 28 Feb 2017 00:04:07 +0000 (00:04 +0000)
committerZachary Turner <zturner@google.com>
Tue, 28 Feb 2017 00:04:07 +0000 (00:04 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296415 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 2a72ddd7641c7a73880b10745ba0b710c17babdb..b7f621d24808cfbc26181710113222fd4ea0a267 100644 (file)
@@ -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;
index d7244de6b749a7dc48a1bee5bc97f91466d7abc5..2a5f20d88ed9207b0b366e7b732f7caa8aeab2d8 100644 (file)
@@ -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;
index b29393a7068e1bca7d519549516f958d62bcebbc..523b9aaeacb60fe3b00b8b0a23833ce5b677f871 100644 (file)
 
 #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 {
index bc5be0498ff0ebc8d10c83ef14a3cda62eba8de1..92177a48d4cd6412c76947a16587bee37684e34e 100644 (file)
@@ -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;
index c77d8edbc15f6f7d900c213d6d284006ca517533..80867ecb41fb1e505c134f06c89fd4d863616a32 100644 (file)
@@ -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))
index 3403956b01ae12a18231693c49eaf1993aa9c554..caa1d7c295fa448fcd222deb7614db2d9e5e0a8c 100644 (file)
@@ -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 WritableBinaryStream {
 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
index f8cad8b289059d7309d9d3090162c20a8c420183..5d4ed5b5118bfbc4ea538c862541cdc3bdf27311 100644 (file)
@@ -34,7 +34,10 @@ template <typename T> struct BinaryItemTraits {
 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;
 };
 
index 50c34e3cba02043512b5a1a01c67e8aab0939fd7..5a9ca34367be6136f3ddd976e54917ec101ff094 100644 (file)
@@ -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.
index 59d3fbe6b31f132f5575337de8ac43ca9a8c051a..507fa5b5689fb5e1fa499d324ff8f849322f31f2 100644 (file)
@@ -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();
index 4d302ff1952df1da26f966a42b4990be49e8ea55..7cbe4e3292f3ef6503d0a03e25434e0b5ae77e95 100644 (file)
@@ -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; }
 
index 585f8f03eabd7a9f5b307294f07733d538c574de..cd4660ef6530e5b99e76c676cef890f4094db899 100644 (file)
@@ -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
index bcaedfd9aac34462edcf79769222c6ba433eb48f..963428453788af887a0ef3c6642f8cdab2acaa33 100644 (file)
@@ -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,
index 08739b697d6b405c9fc5959cf664969ced401070..38d338d6d8305a275e519749a30c1b3ffae79dbb 100644 (file)
@@ -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"
index b08cf6ab9606731053947f1e27670772c4b75738..4133662615be8621e07cd72207b0c16b9ed07c5a 100644 (file)
@@ -19,7 +19,7 @@
 #include "llvm/DebugInfo/PDB/PDBTypes.h"
 
 namespace llvm {
-class BinaryStreamWriter;
+class WritableBinaryStreamRef;
 
 namespace msf {
 class MSFBuilder;
index c39e6a7750fa0f169fb7f39bf3e0cc3322cc09e5..66e1aa7462b657fc52c8744e1dde8bdf3dc72708 100644 (file)
@@ -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;
 }
index 284bbf6237291cb8b73f12a11ec3d52d7e98bc6f..d828e70fcdea5f2e79309b285cf5abb2975b3bed 100644 (file)
@@ -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 {
index 8f51aec0fd03f01c74a64e0c9bea50379ac40ec0..3a98c3a1c908d3dae03b516fed8eee6cfb2b7062 100644 (file)
@@ -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"
 
 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::codeview::CVType> {
   }
 };
 
+namespace codeview {
+class TypeRecord;
+}
 namespace msf {
 class MSFBuilder;
 struct MSFLayout;
index 75cd3d2296c6842443abba836f5a4e4132faa53c..c1dfb900a8db98a1b31f4b03fc49ccfe570b76ab 100644 (file)
@@ -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());
index 5e0ff63dc5a21935302a5e8e3d43d644f0bd726b..a94516985b8a56b84e2ed478cdb545158204864a 100644 (file)
@@ -56,7 +56,7 @@ Error CVTypeDumper::dump(const CVTypeArray &Types,
 }
 
 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()))
index fa7406271e1ef338a86c17e2bee6387a0995e92e..74c60c78b8bfe0008946fb9dccfe243b70387c84 100644 (file)
@@ -182,7 +182,7 @@ Error CVTypeVisitor::visitFieldListMemberStream(BinaryStreamReader Reader) {
 
   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::visitFieldListMemberStream(BinaryStreamReader Reader) {
 }
 
 Error CVTypeVisitor::visitFieldListMemberStream(ArrayRef<uint8_t> Data) {
-  BinaryByteStream S(Data);
+  BinaryByteStream S(Data, llvm::support::little);
   BinaryStreamReader SR(S);
   return visitFieldListMemberStream(SR);
 }
index 3b10f8ff120bc6ae8cc6af922a93b3ae0312ad53..a204d43ba139d687c0d88cdc921b298888d6a836 100644 (file)
@@ -87,14 +87,13 @@ Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes) {
 
 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::mapStringZVectorZ(std::vector<StringRef> &Value) {
       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::mapStringZVectorZ(std::vector<StringRef> &Value) {
 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::writeEncodedSignedInteger(const int64_t &Value) {
 
 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;
   }
 
index d276aa0b84d2bcff86b6d92104b513bb22dec62a..eaa70f2b181298007a85e7f08fe338307d7ba3f7 100644 (file)
@@ -37,7 +37,7 @@ Error llvm::codeview::consume(BinaryStreamReader &Reader, APSInt &Num) {
   // 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(BinaryStreamReader &Reader, APSInt &Num) {
   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(BinaryStreamReader &Reader, APSInt &Num) {
 
 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(BinaryStreamReader &Reader,
 }
 
 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 &Data, uint32_t &Item) {
 }
 
 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) {
index 9074291efccc75020b0cd1453fc92fee46f078df..4d0ce9e4da9c2e5520b33a84f1f87d4ea7f5bd0b 100644 (file)
@@ -76,7 +76,7 @@ TypeSerializer::addPadding(MutableArrayRef<uint8_t> Record) {
   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(MutableArrayRef<uint8_t> Record) {
 
 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(CVMemberRecord &Record) {
 
     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);
 
index 06c34325a5725829ebe0d2ce01f283b616efda93..6ad0c25f0ad8afa4ad603834c3f5881e2ebcdeeb 100644 (file)
@@ -236,7 +236,7 @@ Error DbiStream::initializeSectionContributionData() {
     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)
index f8d443208890b8746c13e83c89a7d72da98c20d8..2dbdceb6571640aec647e8466f95bb3e8a2e8b99 100644 (file)
@@ -153,7 +153,8 @@ Error DbiStreamBuilder::generateModiSubstream() {
   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::generateFileInfoSubstream() {
   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::generateFileInfoSubstream() {
 
   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::generateFileInfoSubstream() {
       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::MSFLayout &Layout,
     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::MSFLayout &Layout,
     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;
   }
index 535799706c87f4a86857494e9b356a025f6e4902..ebf8c9c04db1621fd48ffaf9d84468d878d7943b 100644 (file)
@@ -48,9 +48,9 @@ Error HashTable::load(BinaryStreamReader &Stream) {
                                 "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(BinaryStreamWriter &Writer) const {
     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(BinaryStreamReader &Stream,
 
   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(BinaryStreamWriter &Writer,
                                       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(BinaryStreamWriter &Writer,
       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"));
index 0c2d2c32c6e361715ebbd201b70b3b0d6c727a2c..df9ec818a1d968c65973d691c485c9a09235111c 100644 (file)
@@ -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;
index 91cbf4bca07651edde0938e86e4c17d79d24eaa5..1fa9bc443ecf5ebd8de30ae59b64bf531e67597c 100644 (file)
@@ -31,7 +31,7 @@ Error NamedStreamMap::load(BinaryStreamReader &Stream) {
   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(BinaryStreamWriter &Writer) const {
   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.
index 4c858253b79db217655be508712b7968225dee35..dff53344545aa4373a0d7bb093051d37e3a4de5d 100644 (file)
@@ -45,7 +45,8 @@ Error NativeSession::createFromPdb(StringRef Path,
     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);
index a08ecd0487ef8e529da93561e4922ed6e7008db0..03257c408293b41fe893711671814207bddf7507 100644 (file)
@@ -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))
index 104867d169b7a2730508d354e063608c95201833..18c0cdf03b82f9ec6bd12bfe91625088fc0c03c9 100644 (file)
@@ -118,7 +118,8 @@ Error PDBFileBuilder::commit(StringRef Filename) {
   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 Filename) {
   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))
index e2b9ea20812fa4266fba1a55e1bfca451403689d..79a78c92598acb35e3421d1358b67a4117d91dd1 100644 (file)
@@ -54,7 +54,7 @@ Error StringTable::load(BinaryStreamReader &Stream) {
     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();
 }
index 5432fe4b99efacd25a910063cbd3ba9a1cab4352..9df97c9753ef7961e5aaf54e018b905d85d0a518 100644 (file)
@@ -74,7 +74,7 @@ Error StringTableBuilder::commit(BinaryStreamWriter &Writer) const {
 
   // 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(BinaryStreamWriter &Writer) const {
 
   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();
 }
index 2d351b05b0b09f0dd9b5c4fa75f9674a7c8ddf0b..d38edcb88b87e85c0af64fd54e2ff8ada2851566 100644 (file)
@@ -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;
index 49412b1f95accb0ae545928db44f2b0ee3321077..7d532ee56d834bdc6bb8c8182c5c5bd54507cf06 100644 (file)
@@ -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::finalizeMsfLayout() {
   }
   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();
 }
 
index 50a488620ab4dd032c36e35e374be8bf8f364627..e2b901be868eaab46a46bc009b194aae777d3a8c 100644 (file)
@@ -573,7 +573,7 @@ struct MappingContextTraits<pdb::yaml::PdbTpiFieldListRecord,
     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);
 
index aef9ea530b6cc23bc3456e7dc2a0013e88a00dc5..6de644032142b70ad24bc35cc3b76fc005eac28d 100644 (file)
@@ -840,7 +840,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
     }
     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::printCodeViewSymbolsSubsection(StringRef Subsection,
 
   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::printCodeViewSymbolsSubsection(StringRef Subsection,
 }
 
 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::printCodeViewFileChecksums(StringRef Subsection) {
 }
 
 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::printCodeViewInlineeLines(StringRef Subsection) {
 
     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(TypeTableBuilder &CVTypes) {
         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())) {
index 1e85257e71387e4ebfbc4dce961437214c4d9999..fae7d375e1719191e838a79705c35196fe018319 100644 (file)
@@ -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.
index 20f5c412d881b01c7cd518d1c2eeaaa5c4fc09f5..42f38a2e2e492d7e2b2901fe7212f763765cc0b2 100644 (file)
@@ -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, TestWriteThenRead) {
 
   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, TestWriteThenRead) {
   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, TestWriteThenRead) {
   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, TestWriteContiguousStreamRef) {
       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>(
index bc5420038e61b39a787da3a9824b677356a98bf2..aecffbe9b011f6dd83da7c02c863ebcf23e661ec 100644 (file)
@@ -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));