[llvm] r270751 - [codeview] Move StreamInterface and StreamReader to libcodeview.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 13:37:04 PDT 2016


Author: zturner
Date: Wed May 25 15:37:03 2016
New Revision: 270751

URL: http://llvm.org/viewvc/llvm-project?rev=270751&view=rev
Log:
[codeview] Move StreamInterface and StreamReader to libcodeview.

We have need to reuse this functionality, including making
additional generic stream types that are smarter about how and
when they copy memory versus referencing the original memory.
So all of these structures belong in the common library
rather than being pdb specific.

Added:
    llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h
      - copied, changed from r270750, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ByteStream.h
    llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewError.h
    llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h
      - copied, changed from r270750, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h
    llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h
      - copied, changed from r270750, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamReader.h
    llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp
      - copied, changed from r270750, llvm/trunk/lib/DebugInfo/PDB/Raw/ByteStream.cpp
    llvm/trunk/lib/DebugInfo/CodeView/CodeViewError.cpp
    llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp
      - copied, changed from r270750, llvm/trunk/lib/DebugInfo/PDB/Raw/StreamReader.cpp
Removed:
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ByteStream.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamReader.h
    llvm/trunk/lib/DebugInfo/PDB/Raw/ByteStream.cpp
    llvm/trunk/lib/DebugInfo/PDB/Raw/StreamReader.cpp
Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h
    llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
    llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt
    llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp
    llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp
    llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp
    llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
    llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp
    llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
    llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
    llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp
    llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp

Copied: llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h (from r270750, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ByteStream.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h?p2=llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ByteStream.h&r1=270750&r2=270751&rev=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ByteStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h Wed May 25 15:37:03 2016
@@ -7,19 +7,18 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_DEBUGINFO_PDB_RAW_BYTESTREAM_H
-#define LLVM_DEBUGINFO_PDB_RAW_BYTESTREAM_H
+#ifndef LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
+#define LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamInterface.h"
+#include "llvm/DebugInfo/CodeView/StreamInterface.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
 #include <memory>
 
 namespace llvm {
-namespace pdb {
-
+namespace codeview {
 class StreamReader;
 
 class ByteStream : public StreamInterface {
@@ -53,4 +52,4 @@ private:
 } // end namespace pdb
 } // end namespace llvm
 
-#endif // LLVM_DEBUGINFO_PDB_RAW_BYTESTREAM_H
+#endif // LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H

Added: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewError.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewError.h?rev=270751&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewError.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewError.h Wed May 25 15:37:03 2016
@@ -0,0 +1,43 @@
+//===- CodeViewError.h - Error extensions for CodeView ----------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H
+#define LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H
+
+#include "llvm/Support/Error.h"
+
+#include <string>
+
+namespace llvm {
+namespace codeview {
+enum class cv_error_code {
+  unspecified = 1,
+  insufficient_buffer,
+  corrupt_record,
+};
+
+/// Base class for errors originating when parsing raw PDB files
+class CodeViewError : public ErrorInfo<CodeViewError> {
+public:
+  static char ID;
+  CodeViewError(cv_error_code C);
+  CodeViewError(const std::string &Context);
+  CodeViewError(cv_error_code C, const std::string &Context);
+
+  void log(raw_ostream &OS) const override;
+  const std::string &getErrorMessage() const;
+  std::error_code convertToErrorCode() const override;
+
+private:
+  std::string ErrMsg;
+  cv_error_code Code;
+};
+}
+}
+#endif

Copied: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h (from r270750, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h?p2=llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h&r1=270750&r2=270751&rev=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h Wed May 25 15:37:03 2016
@@ -1,4 +1,4 @@
-//===- StreamInterface.h - Base interface for a PDB stream ------*- C++ -*-===//
+//===- StreamInterface.h - Base interface for a stream of data --*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,15 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_DEBUGINFO_PDB_RAW_STREAMINTERFACE_H
-#define LLVM_DEBUGINFO_PDB_RAW_STREAMINTERFACE_H
+#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H
+#define LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
 
 namespace llvm {
-namespace pdb {
+namespace codeview {
 
 class StreamInterface {
 public:
@@ -29,7 +29,7 @@ public:
   virtual uint32_t getLength() const = 0;
 };
 
-} // end namespace pdb
+} // end namespace codeview
 } // end namespace llvm
 
-#endif // LLVM_DEBUGINFO_PDB_RAW_STREAMINTERFACE_H
+#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H

Copied: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h (from r270750, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamReader.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h?p2=llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamReader.h&r1=270750&r2=270751&rev=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamReader.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h Wed May 25 15:37:03 2016
@@ -7,19 +7,19 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_DEBUGINFO_PDB_RAW_STREAMREADER_H
-#define LLVM_DEBUGINFO_PDB_RAW_STREAMREADER_H
+#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
+#define LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
 
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamInterface.h"
+#include "llvm/DebugInfo/CodeView/StreamInterface.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 
 #include <string>
 
 namespace llvm {
-namespace pdb {
-class StreamInterface;
+namespace codeview {
+
 class StreamReader {
 public:
   StreamReader(const StreamInterface &S);
@@ -35,7 +35,8 @@ public:
   }
 
   template <typename T> Error readArray(MutableArrayRef<T> Array) {
-    MutableArrayRef<uint8_t> Casted(reinterpret_cast<uint8_t*>(Array.data()), Array.size() * sizeof(T));
+    MutableArrayRef<uint8_t> Casted(reinterpret_cast<uint8_t *>(Array.data()),
+                                    Array.size() * sizeof(T));
     return readBytes(Casted);
   }
 
@@ -50,7 +51,7 @@ private:
   const StreamInterface &Stream;
   uint32_t Offset;
 };
-}
-}
+} // namespace codeview
+} // namespace llvm
 
-#endif
+#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H

Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ByteStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ByteStream.h?rev=270750&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ByteStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ByteStream.h (removed)
@@ -1,56 +0,0 @@
-//===- ByteStream.h - Reads stream data from a byte sequence ----*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_PDB_RAW_BYTESTREAM_H
-#define LLVM_DEBUGINFO_PDB_RAW_BYTESTREAM_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamInterface.h"
-#include "llvm/Support/Error.h"
-#include <cstdint>
-#include <memory>
-
-namespace llvm {
-namespace pdb {
-
-class StreamReader;
-
-class ByteStream : public StreamInterface {
-public:
-  ByteStream();
-  explicit ByteStream(MutableArrayRef<uint8_t> Bytes);
-  explicit ByteStream(uint32_t Length);
-  ~ByteStream() override;
-
-  void reset();
-  void initialize(MutableArrayRef<uint8_t> Bytes);
-  void initialize(uint32_t Length);
-  Error initialize(StreamReader &Reader, uint32_t Length);
-
-  Error readBytes(uint32_t Offset,
-                  MutableArrayRef<uint8_t> Buffer) const override;
-
-  Error getArrayRef(uint32_t Offset, ArrayRef<uint8_t> &Buffer,
-                    uint32_t Length) const override;
-
-  uint32_t getLength() const override;
-
-  ArrayRef<uint8_t> data() const { return Data; }
-  StringRef str() const;
-
-private:
-  MutableArrayRef<uint8_t> Data;
-  std::unique_ptr<uint8_t[]> Ownership;
-};
-
-} // end namespace pdb
-} // end namespace llvm
-
-#endif // LLVM_DEBUGINFO_PDB_RAW_BYTESTREAM_H

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h Wed May 25 15:37:03 2016
@@ -10,8 +10,8 @@
 #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H
 #define LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H
 
+#include "llvm/DebugInfo/CodeView/ByteStream.h"
 #include "llvm/DebugInfo/PDB/PDBTypes.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
 #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
 #include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
 #include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
@@ -62,13 +62,13 @@ private:
   std::vector<ModuleInfoEx> ModuleInfos;
   NameHashTable ECNames;
 
-  ByteStream ModInfoSubstream;
-  ByteStream SecContrSubstream;
-  ByteStream SecMapSubstream;
-  ByteStream FileInfoSubstream;
-  ByteStream TypeServerMapSubstream;
-  ByteStream ECSubstream;
-  ByteStream DbgHeader;
+  codeview::ByteStream ModInfoSubstream;
+  codeview::ByteStream SecContrSubstream;
+  codeview::ByteStream SecMapSubstream;
+  codeview::ByteStream FileInfoSubstream;
+  codeview::ByteStream TypeServerMapSubstream;
+  codeview::ByteStream ECSubstream;
+  codeview::ByteStream DbgHeader;
 
   std::unique_ptr<HeaderInfo> Header;
 };

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h Wed May 25 15:37:03 2016
@@ -11,7 +11,7 @@
 #define LLVM_DEBUGINFO_PDB_RAW_MAPPEDBLOCKSTREAM_H
 
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamInterface.h"
+#include "llvm/DebugInfo/CodeView/StreamInterface.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
 #include <vector>
@@ -21,7 +21,7 @@ namespace pdb {
 
 class PDBFile;
 
-class MappedBlockStream : public StreamInterface {
+class MappedBlockStream : public codeview::StreamInterface {
 public:
   MappedBlockStream(uint32_t StreamIdx, const PDBFile &File);
 

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h Wed May 25 15:37:03 2016
@@ -11,8 +11,8 @@
 #define LLVM_DEBUGINFO_PDB_RAW_MODSTREAM_H
 
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/DebugInfo/CodeView/ByteStream.h"
 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
 #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
 #include "llvm/Support/Error.h"
 
@@ -35,10 +35,10 @@ private:
 
   MappedBlockStream Stream;
 
-  ByteStream SymbolsSubstream;
-  ByteStream LinesSubstream;
-  ByteStream C13LinesSubstream;
-  ByteStream GlobalRefsSubstream;
+  codeview::ByteStream SymbolsSubstream;
+  codeview::ByteStream LinesSubstream;
+  codeview::ByteStream C13LinesSubstream;
+  codeview::ByteStream GlobalRefsSubstream;
 };
 }
 }

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h Wed May 25 15:37:03 2016
@@ -12,21 +12,22 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
+#include "llvm/DebugInfo/CodeView/ByteStream.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
 #include <vector>
 
 namespace llvm {
-namespace pdb {
-
+namespace codeview {
 class StreamReader;
+}
+namespace pdb {
 
 class NameHashTable {
 public:
   NameHashTable();
 
-  Error load(StreamReader &Stream);
+  Error load(codeview::StreamReader &Stream);
 
   uint32_t getNameCount() const { return NameCount; }
   uint32_t getHashVersion() const { return HashVersion; }
@@ -38,7 +39,7 @@ public:
   ArrayRef<uint32_t> name_ids() const;
 
 private:
-  ByteStream NamesBuffer;
+  codeview::ByteStream NamesBuffer;
   std::vector<uint32_t> IDs;
   uint32_t Signature;
   uint32_t HashVersion;

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h Wed May 25 15:37:03 2016
@@ -16,15 +16,16 @@
 #include <cstdint>
 
 namespace llvm {
-namespace pdb {
-
+namespace codeview {
 class StreamReader;
+}
+namespace pdb {
 
 class NameMap {
 public:
   NameMap();
 
-  Error load(StreamReader &Stream);
+  Error load(codeview::StreamReader &Stream);
 
   bool tryGetValue(StringRef Name, uint32_t &Value) const;
 

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h Wed May 25 15:37:03 2016
@@ -13,7 +13,6 @@
 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
 #include "llvm/DebugInfo/CodeView/TypeStream.h"
 #include "llvm/DebugInfo/PDB/PDBTypes.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
 #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
 #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
 

Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h?rev=270750&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h (removed)
@@ -1,35 +0,0 @@
-//===- StreamInterface.h - Base interface for a PDB stream ------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_PDB_RAW_STREAMINTERFACE_H
-#define LLVM_DEBUGINFO_PDB_RAW_STREAMINTERFACE_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/Support/Error.h"
-#include <cstdint>
-
-namespace llvm {
-namespace pdb {
-
-class StreamInterface {
-public:
-  virtual ~StreamInterface() {}
-
-  virtual Error readBytes(uint32_t Offset,
-                          MutableArrayRef<uint8_t> Buffer) const = 0;
-  virtual Error getArrayRef(uint32_t Offset, ArrayRef<uint8_t> &Buffer,
-                            uint32_t Length) const = 0;
-
-  virtual uint32_t getLength() const = 0;
-};
-
-} // end namespace pdb
-} // end namespace llvm
-
-#endif // LLVM_DEBUGINFO_PDB_RAW_STREAMINTERFACE_H

Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamReader.h?rev=270750&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamReader.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/StreamReader.h (removed)
@@ -1,56 +0,0 @@
-//===- StreamReader.h - Reads bytes and objects from a stream ---*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_PDB_RAW_STREAMREADER_H
-#define LLVM_DEBUGINFO_PDB_RAW_STREAMREADER_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamInterface.h"
-#include "llvm/Support/Endian.h"
-#include "llvm/Support/Error.h"
-
-#include <string>
-
-namespace llvm {
-namespace pdb {
-class StreamInterface;
-class StreamReader {
-public:
-  StreamReader(const StreamInterface &S);
-
-  Error readBytes(MutableArrayRef<uint8_t> Buffer);
-  Error readInteger(uint32_t &Dest);
-  Error readZeroString(std::string &Dest);
-
-  template <typename T> Error readObject(T *Dest) {
-    MutableArrayRef<uint8_t> Buffer(reinterpret_cast<uint8_t *>(Dest),
-                                    sizeof(T));
-    return readBytes(Buffer);
-  }
-
-  template <typename T> Error readArray(MutableArrayRef<T> Array) {
-    MutableArrayRef<uint8_t> Casted(reinterpret_cast<uint8_t*>(Array.data()), Array.size() * sizeof(T));
-    return readBytes(Casted);
-  }
-
-  Error getArrayRef(ArrayRef<uint8_t> &Array, uint32_t Length);
-
-  void setOffset(uint32_t Off) { Offset = Off; }
-  uint32_t getOffset() const { return Offset; }
-  uint32_t getLength() const { return Stream.getLength(); }
-  uint32_t bytesRemaining() const { return getLength() - getOffset(); }
-
-private:
-  const StreamInterface &Stream;
-  uint32_t Offset;
-};
-}
-}
-
-#endif

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h Wed May 25 15:37:03 2016
@@ -10,8 +10,8 @@
 #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H
 #define LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H
 
+#include "llvm/DebugInfo/CodeView/ByteStream.h"
 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
 #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
 
 #include "llvm/Support/Error.h"
@@ -29,7 +29,7 @@ public:
   iterator_range<codeview::SymbolIterator> getSymbols() const;
 
 private:
-  ByteStream Stream;
+  codeview::ByteStream Stream;
   MappedBlockStream MappedStream;
 };
 }

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h Wed May 25 15:37:03 2016
@@ -10,9 +10,9 @@
 #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H
 #define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H
 
+#include "llvm/DebugInfo/CodeView/ByteStream.h"
 #include "llvm/DebugInfo/CodeView/TypeStream.h"
 #include "llvm/DebugInfo/PDB/PDBTypes.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
 #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
 #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
 
@@ -47,10 +47,10 @@ private:
   MappedBlockStream Stream;
   HashFunctionType HashFunction;
 
-  ByteStream RecordsBuffer;
-  ByteStream TypeIndexOffsetBuffer;
-  ByteStream HashValuesBuffer;
-  ByteStream HashAdjBuffer;
+  codeview::ByteStream RecordsBuffer;
+  codeview::ByteStream TypeIndexOffsetBuffer;
+  codeview::ByteStream HashValuesBuffer;
+  codeview::ByteStream HashAdjBuffer;
 
   std::unique_ptr<HeaderInfo> Header;
 };

Copied: llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp (from r270750, llvm/trunk/lib/DebugInfo/PDB/Raw/ByteStream.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp?p2=llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp&p1=llvm/trunk/lib/DebugInfo/PDB/Raw/ByteStream.cpp&r1=270750&r2=270751&rev=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/ByteStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp Wed May 25 15:37:03 2016
@@ -7,13 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
-#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
+#include "llvm/DebugInfo/CodeView/ByteStream.h"
+#include "llvm/DebugInfo/CodeView/CodeViewError.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include <cstring>
 
 using namespace llvm;
-using namespace llvm::pdb;
+using namespace llvm::codeview;
 
 ByteStream::ByteStream() {}
 
@@ -51,7 +51,7 @@ Error ByteStream::initialize(StreamReade
 Error ByteStream::readBytes(uint32_t Offset,
                             MutableArrayRef<uint8_t> Buffer) const {
   if (Data.size() < Buffer.size() + Offset)
-    return make_error<RawError>(raw_error_code::insufficient_buffer);
+    return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
   ::memcpy(Buffer.data(), Data.data() + Offset, Buffer.size());
   return Error::success();
 }
@@ -59,7 +59,7 @@ Error ByteStream::readBytes(uint32_t Off
 Error ByteStream::getArrayRef(uint32_t Offset, ArrayRef<uint8_t> &Buffer,
                               uint32_t Length) const {
   if (Data.size() < Length + Offset)
-    return make_error<RawError>(raw_error_code::insufficient_buffer);
+    return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
   Buffer = Data.slice(Offset, Length);
   return Error::success();
 }

Modified: llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt Wed May 25 15:37:03 2016
@@ -1,10 +1,13 @@
 add_llvm_library(LLVMDebugInfoCodeView
+  ByteStream.cpp
+  CodeViewError.cpp
   FieldListRecordBuilder.cpp
   Line.cpp
   ListRecordBuilder.cpp
   MemoryTypeTableBuilder.cpp
   MethodListRecordBuilder.cpp
   RecordSerialization.cpp
+  StreamReader.cpp
   SymbolDumper.cpp
   TypeDumper.cpp
   TypeRecord.cpp

Added: llvm/trunk/lib/DebugInfo/CodeView/CodeViewError.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CodeViewError.cpp?rev=270751&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CodeViewError.cpp (added)
+++ llvm/trunk/lib/DebugInfo/CodeView/CodeViewError.cpp Wed May 25 15:37:03 2016
@@ -0,0 +1,65 @@
+//===- CodeViewError.cpp - Error extensions for CodeView --------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/CodeViewError.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ManagedStatic.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+namespace {
+// FIXME: This class is only here to support the transition to llvm::Error. It
+// will be removed once this transition is complete. Clients should prefer to
+// deal with the Error value directly, rather than converting to error_code.
+class CodeViewErrorCategory : public std::error_category {
+public:
+  const char *name() const LLVM_NOEXCEPT override { return "llvm.codeview"; }
+
+  std::string message(int Condition) const override {
+    switch (static_cast<cv_error_code>(Condition)) {
+    case cv_error_code::unspecified:
+      return "An unknown error has occurred.";
+    case cv_error_code::insufficient_buffer:
+      return "The buffer is not large enough to read the requested number of "
+             "bytes.";
+    case cv_error_code::corrupt_record:
+      return "The CodeView record is corrupted.";
+    }
+    llvm_unreachable("Unrecognized cv_error_code");
+  }
+};
+} // end anonymous namespace
+
+static ManagedStatic<CodeViewErrorCategory> Category;
+
+char CodeViewError::ID = 0;
+
+CodeViewError::CodeViewError(cv_error_code C) : CodeViewError(C, "") {}
+
+CodeViewError::CodeViewError(const std::string &Context)
+    : CodeViewError(cv_error_code::unspecified, Context) {}
+
+CodeViewError::CodeViewError(cv_error_code C, const std::string &Context)
+    : Code(C) {
+  ErrMsg = "CodeView Error: ";
+  std::error_code EC = convertToErrorCode();
+  if (Code != cv_error_code::unspecified)
+    ErrMsg += EC.message() + "  ";
+  if (!Context.empty())
+    ErrMsg += Context;
+}
+
+void CodeViewError::log(raw_ostream &OS) const { OS << ErrMsg << "\n"; }
+
+const std::string &CodeViewError::getErrorMessage() const { return ErrMsg; }
+
+std::error_code CodeViewError::convertToErrorCode() const {
+  return std::error_code(static_cast<int>(Code), *Category);
+}

Copied: llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp (from r270750, llvm/trunk/lib/DebugInfo/PDB/Raw/StreamReader.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp?p2=llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp&p1=llvm/trunk/lib/DebugInfo/PDB/Raw/StreamReader.cpp&r1=270750&r2=270751&rev=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/StreamReader.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp Wed May 25 15:37:03 2016
@@ -7,11 +7,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
-#include "llvm/DebugInfo/PDB/Raw/RawError.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
+
+#include "llvm/DebugInfo/CodeView/CodeViewError.h"
 
 using namespace llvm;
-using namespace llvm::pdb;
+using namespace llvm::codeview;
 
 StreamReader::StreamReader(const StreamInterface &S) : Stream(S), Offset(0) {}
 

Modified: llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt Wed May 25 15:37:03 2016
@@ -28,7 +28,6 @@ if(HAVE_DIA_SDK)
 endif()
 
 add_pdb_impl_folder(Raw
-  Raw/ByteStream.cpp
   Raw/DbiStream.cpp
   Raw/InfoStream.cpp
   Raw/MappedBlockStream.cpp
@@ -40,7 +39,6 @@ add_pdb_impl_folder(Raw
   Raw/PublicsStream.cpp
   Raw/RawError.cpp
   Raw/RawSession.cpp
-  Raw/StreamReader.cpp
   Raw/SymbolStream.cpp
   Raw/TpiStream.cpp)
 

Removed: llvm/trunk/lib/DebugInfo/PDB/Raw/ByteStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/ByteStream.cpp?rev=270750&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/ByteStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/ByteStream.cpp (removed)
@@ -1,72 +0,0 @@
-//===- ByteStream.cpp - Reads stream data from a byte sequence ------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
-#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
-#include <cstring>
-
-using namespace llvm;
-using namespace llvm::pdb;
-
-ByteStream::ByteStream() {}
-
-ByteStream::ByteStream(MutableArrayRef<uint8_t> Bytes) { initialize(Bytes); }
-
-ByteStream::ByteStream(uint32_t Length) { initialize(Length); }
-
-ByteStream::~ByteStream() { reset(); }
-
-void ByteStream::reset() {
-  Ownership.reset();
-  Data = MutableArrayRef<uint8_t>();
-}
-
-void ByteStream::initialize(MutableArrayRef<uint8_t> Bytes) {
-  reset();
-  Data = Bytes;
-}
-
-void ByteStream::initialize(uint32_t Length) {
-  reset();
-  if (Length > 0)
-    Data = MutableArrayRef<uint8_t>(new uint8_t[Length], Length);
-  Ownership.reset(Data.data());
-}
-
-Error ByteStream::initialize(StreamReader &Reader, uint32_t Length) {
-  initialize(Length);
-  auto EC = Reader.readBytes(Data);
-  if (EC)
-    reset();
-  return EC;
-}
-
-Error ByteStream::readBytes(uint32_t Offset,
-                            MutableArrayRef<uint8_t> Buffer) const {
-  if (Data.size() < Buffer.size() + Offset)
-    return make_error<RawError>(raw_error_code::insufficient_buffer);
-  ::memcpy(Buffer.data(), Data.data() + Offset, Buffer.size());
-  return Error::success();
-}
-
-Error ByteStream::getArrayRef(uint32_t Offset, ArrayRef<uint8_t> &Buffer,
-                              uint32_t Length) const {
-  if (Data.size() < Length + Offset)
-    return make_error<RawError>(raw_error_code::insufficient_buffer);
-  Buffer = Data.slice(Offset, Length);
-  return Error::success();
-}
-
-uint32_t ByteStream::getLength() const { return Data.size(); }
-
-StringRef ByteStream::str() const {
-  const char *CharData = reinterpret_cast<const char *>(Data.data());
-  return StringRef(CharData, Data.size());
-}

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp Wed May 25 15:37:03 2016
@@ -9,13 +9,13 @@
 
 #include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
 
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
 #include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
 #include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
 #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
 #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 using namespace llvm;
 using namespace llvm::pdb;
@@ -80,7 +80,7 @@ DbiStream::DbiStream(PDBFile &File) : Pd
 DbiStream::~DbiStream() {}
 
 Error DbiStream::reload() {
-  StreamReader Reader(Stream);
+  codeview::StreamReader Reader(Stream);
 
   Header.reset(new HeaderInfo());
 
@@ -170,7 +170,7 @@ Error DbiStream::reload() {
     return make_error<RawError>(raw_error_code::corrupt_file,
                                 "Found unexpected bytes in DBI Stream.");
 
-  StreamReader ECReader(ECSubstream);
+  codeview::StreamReader ECReader(ECSubstream);
   if (auto EC = ECNames.load(ECReader))
     return EC;
 

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp Wed May 25 15:37:03 2016
@@ -10,9 +10,9 @@
 #include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 using namespace llvm;
 using namespace llvm::pdb;
@@ -20,7 +20,7 @@ using namespace llvm::pdb;
 InfoStream::InfoStream(PDBFile &File) : Pdb(File), Stream(StreamPDB, File) {}
 
 Error InfoStream::reload() {
-  StreamReader Reader(Stream);
+  codeview::StreamReader Reader(Stream);
 
   struct Header {
     support::ulittle32_t Version;

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp Wed May 25 15:37:03 2016
@@ -8,9 +8,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/DebugInfo/PDB/Raw/ModStream.h"
+
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
 #include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 using namespace llvm;
 using namespace llvm::pdb;
@@ -21,7 +22,7 @@ ModStream::ModStream(PDBFile &File, cons
 ModStream::~ModStream() {}
 
 Error ModStream::reload() {
-  StreamReader Reader(Stream);
+  codeview::StreamReader Reader(Stream);
 
   uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
   uint32_t C11Size = Mod.getLineInfoByteSize();

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp Wed May 25 15:37:03 2016
@@ -10,9 +10,8 @@
 #include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
 
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 #include "llvm/Support/Endian.h"
 
 using namespace llvm;
@@ -78,7 +77,7 @@ static inline uint32_t HashStringV2(Stri
 
 NameHashTable::NameHashTable() : Signature(0), HashVersion(0), NameCount(0) {}
 
-Error NameHashTable::load(StreamReader &Stream) {
+Error NameHashTable::load(codeview::StreamReader &Stream) {
   struct Header {
     support::ulittle32_t Signature;
     support::ulittle32_t HashVersion;

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp Wed May 25 15:37:03 2016
@@ -9,15 +9,15 @@
 
 #include "llvm/DebugInfo/PDB/Raw/NameMap.h"
 #include "llvm/ADT/BitVector.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 using namespace llvm;
 using namespace llvm::pdb;
 
 NameMap::NameMap() {}
 
-Error NameMap::load(StreamReader &Stream) {
+Error NameMap::load(codeview::StreamReader &Stream) {
 
   // This is some sort of weird string-set/hash table encoded in the stream.
   // It starts with the number of bytes in the table.

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp Wed May 25 15:37:03 2016
@@ -25,12 +25,12 @@
 #include "llvm/DebugInfo/PDB/Raw/PublicsStream.h"
 
 #include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
 #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
 #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
 #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 #include "llvm/DebugInfo/PDB/Raw/SymbolStream.h"
 
 #include "llvm/ADT/BitVector.h"
@@ -99,7 +99,7 @@ uint32_t PublicsStream::getAddrMap() con
 // we skip over the hash table which we believe contains information about
 // public symbols.
 Error PublicsStream::reload() {
-  StreamReader Reader(Stream);
+  codeview::StreamReader Reader(Stream);
 
   // Check stream size.
   if (Reader.bytesRemaining() < sizeof(HeaderInfo) + sizeof(GSIHashHeader))

Removed: llvm/trunk/lib/DebugInfo/PDB/Raw/StreamReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/StreamReader.cpp?rev=270750&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/StreamReader.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/StreamReader.cpp (removed)
@@ -1,50 +0,0 @@
-//===- StreamReader.cpp - Reads bytes and objects from a stream -----------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
-#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-
-using namespace llvm;
-using namespace llvm::pdb;
-
-StreamReader::StreamReader(const StreamInterface &S) : Stream(S), Offset(0) {}
-
-Error StreamReader::readBytes(MutableArrayRef<uint8_t> Buffer) {
-  if (auto EC = Stream.readBytes(Offset, Buffer))
-    return EC;
-  Offset += Buffer.size();
-  return Error::success();
-}
-
-Error StreamReader::readInteger(uint32_t &Dest) {
-  support::ulittle32_t P;
-  if (auto EC = readObject(&P))
-    return EC;
-  Dest = P;
-  return Error::success();
-}
-
-Error StreamReader::readZeroString(std::string &Dest) {
-  Dest.clear();
-  char C;
-  do {
-    if (auto EC = readObject(&C))
-      return EC;
-    if (C != '\0')
-      Dest.push_back(C);
-  } while (C != '\0');
-  return Error::success();
-}
-
-Error StreamReader::getArrayRef(ArrayRef<uint8_t> &Array, uint32_t Length) {
-  if (auto EC = Stream.getArrayRef(Offset, Array, Length))
-    return EC;
-  Offset += Length;
-  return Error::success();
-}

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp Wed May 25 15:37:03 2016
@@ -10,12 +10,11 @@
 #include "llvm/DebugInfo/PDB/Raw/SymbolStream.h"
 
 #include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
 #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
 #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 #include "llvm/Support/Endian.h"
 
@@ -29,7 +28,7 @@ SymbolStream::SymbolStream(PDBFile &File
 SymbolStream::~SymbolStream() {}
 
 Error SymbolStream::reload() {
-  StreamReader Reader(MappedStream);
+  codeview::StreamReader Reader(MappedStream);
 
   if (Stream.initialize(Reader, MappedStream.getLength()))
     return make_error<RawError>(raw_error_code::corrupt_file,

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp Wed May 25 15:37:03 2016
@@ -10,11 +10,11 @@
 #include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
 
 #include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
 #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
 #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 #include "llvm/Support/Endian.h"
 
@@ -62,7 +62,7 @@ TpiStream::TpiStream(PDBFile &File, uint
 TpiStream::~TpiStream() {}
 
 Error TpiStream::reload() {
-  StreamReader Reader(Stream);
+  codeview::StreamReader Reader(Stream);
 
   if (Reader.bytesRemaining() < sizeof(HeaderInfo))
     return make_error<RawError>(raw_error_code::corrupt_file,
@@ -98,7 +98,7 @@ Error TpiStream::reload() {
 
   // Hash indices, hash values, etc come from the hash stream.
   MappedBlockStream HS(Header->HashStreamIndex, Pdb);
-  StreamReader HSR(HS);
+  codeview::StreamReader HSR(HS);
   HSR.setOffset(Header->HashValueBuffer.Off);
   if (auto EC =
           HashValuesBuffer.initialize(HSR, Header->HashValueBuffer.Length))

Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=270751&r1=270750&r2=270751&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Wed May 25 15:37:03 2016
@@ -26,6 +26,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Config/config.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
 #include "llvm/DebugInfo/CodeView/SymbolDumper.h"
 #include "llvm/DebugInfo/CodeView/TypeDumper.h"
 #include "llvm/DebugInfo/PDB/GenericError.h"
@@ -48,7 +49,6 @@
 #include "llvm/DebugInfo/PDB/Raw/PublicsStream.h"
 #include "llvm/DebugInfo/PDB/Raw/RawError.h"
 #include "llvm/DebugInfo/PDB/Raw/RawSession.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 #include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConvertUTF.h"
@@ -343,7 +343,7 @@ static Error dumpStreamData(ScopedPrinte
     return Error::success();
 
   MappedBlockStream S(DumpStreamNum, File);
-  StreamReader R(S);
+  codeview::StreamReader R(S);
   while (R.bytesRemaining() > 0) {
     ArrayRef<uint8_t> Data;
     uint32_t BytesToReadInBlock = std::min(
@@ -393,7 +393,7 @@ static Error dumpNamedStream(ScopedPrint
     P.printNumber("Index", NameStreamIndex);
 
     MappedBlockStream NameStream(NameStreamIndex, File);
-    StreamReader Reader(NameStream);
+    codeview::StreamReader Reader(NameStream);
 
     NameHashTable NameTable;
     if (auto EC = NameTable.load(Reader))




More information about the llvm-commits mailing list