<div dir="ltr">That doesn't make much sense to me. What's uninitialized? That line initializes Iter by definition, as it invokes the default constructor.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, May 31, 2016 at 3:20 PM Mehdi Amini <<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On May 27, 2016, at 10:21 PM, Zachary Turner via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: zturner<br>
> Date: Sat May 28 00:21:57 2016<br>
> New Revision: 271101<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=271101&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=271101&view=rev</a><br>
> Log:<br>
> [pdb] Finish conversion to zero copy pdb access.<br>
><br>
> This converts remaining uses of ByteStream, which was still<br>
> left in the symbol stream and type stream, to using the new<br>
> StreamInterface zero-copy classes.<br>
><br>
> RecordIterator is finally deleted, so this is the only way left<br>
> now. Additionally, more error checking is added when iterating<br>
> the various streams.<br>
><br>
> With this, the transition to zero copy pdb access is complete.<br>
><br>
> Added:<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h<br>
> Removed:<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/RecordIterator.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStream.h<br>
> Modified:<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDumper.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h<br>
> llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h<br>
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h<br>
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h<br>
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h<br>
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h<br>
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h<br>
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h<br>
> llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp<br>
> llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp<br>
> llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp<br>
> llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp<br>
> llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp<br>
> llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp<br>
> llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp<br>
> llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp<br>
> llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp<br>
> llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp<br>
> llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp<br>
> llvm/trunk/tools/llvm-readobj/COFFDumper.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h Sat May 28 00:21:57 2016<br>
> @@ -24,16 +24,9 @@ class StreamReader;<br>
> class ByteStream : public StreamInterface {<br>
> public:<br>
> ByteStream();<br>
> - explicit ByteStream(MutableArrayRef<uint8_t> Data);<br>
> + explicit ByteStream(ArrayRef<uint8_t> Data);<br>
> ~ByteStream() override;<br>
><br>
> - void reset();<br>
> -<br>
> - void load(uint32_t Length);<br>
> - Error load(StreamReader &Reader, uint32_t Length);<br>
> -<br>
> - Error readBytes(uint32_t Offset,<br>
> - MutableArrayRef<uint8_t> Buffer) const override;<br>
> Error readBytes(uint32_t Offset, uint32_t Size,<br>
> ArrayRef<uint8_t> &Buffer) const override;<br>
><br>
> @@ -43,8 +36,7 @@ public:<br>
> StringRef str() const;<br>
><br>
> private:<br>
> - MutableArrayRef<uint8_t> Data;<br>
> - std::unique_ptr<uint8_t[]> Ownership;<br>
> + ArrayRef<uint8_t> Data;<br>
> };<br>
><br>
> } // end namespace pdb<br>
><br>
> Added: llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h?rev=271101&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h?rev=271101&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h (added)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h Sat May 28 00:21:57 2016<br>
> @@ -0,0 +1,47 @@<br>
> +//===- RecordIterator.h -----------------------------------------*- C++ -*-===//<br>
> +//<br>
> +// The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H<br>
> +#define LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H<br>
> +<br>
> +#include "llvm/ADT/ArrayRef.h"<br>
> +#include "llvm/ADT/iterator_range.h"<br>
> +#include "llvm/DebugInfo/CodeView/RecordSerialization.h"<br>
> +#include "llvm/DebugInfo/CodeView/StreamInterface.h"<br>
> +#include "llvm/DebugInfo/CodeView/StreamReader.h"<br>
> +#include "llvm/Support/Endian.h"<br>
> +<br>
> +namespace llvm {<br>
> +namespace codeview {<br>
> +<br>
> +template <typename Kind> struct CVRecord {<br>
> + uint32_t Length;<br>
> + Kind Type;<br>
> + ArrayRef<uint8_t> Data;<br>
> +};<br>
> +<br>
> +template <typename Kind> struct VarStreamArrayExtractor<CVRecord<Kind>> {<br>
> + Error operator()(const StreamInterface &Stream, uint32_t &Len,<br>
> + CVRecord<Kind> &Item) const {<br>
> + const RecordPrefix *Prefix = nullptr;<br>
> + StreamReader Reader(Stream);<br>
> + if (auto EC = Reader.readObject(Prefix))<br>
> + return EC;<br>
> + Item.Length = Prefix->RecordLen;<br>
> + Item.Type = static_cast<Kind>(uint16_t(Prefix->RecordKind));<br>
> + if (auto EC = Reader.readBytes(Item.Data, Item.Length - 2))<br>
> + return EC;<br>
> + Len = Prefix->RecordLen + 2;<br>
> + return Error::success();<br>
> + }<br>
> +};<br>
> +}<br>
> +}<br>
> +<br>
> +#endif<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h Sat May 28 00:21:57 2016<br>
> @@ -10,8 +10,8 @@<br>
> #ifndef LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H<br>
> #define LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H<br>
><br>
> +#include "llvm/DebugInfo/CodeView/CVRecord.h"<br>
> #include "llvm/DebugInfo/CodeView/CodeView.h"<br>
> -#include "llvm/DebugInfo/CodeView/RecordIterator.h"<br>
> #include "llvm/DebugInfo/CodeView/SymbolRecord.h"<br>
> #include "llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h"<br>
> #include "llvm/Support/ErrorOr.h"<br>
> @@ -72,8 +72,8 @@ public:<br>
> }<br>
><br>
> /// Visits the symbol records in Data. Sets the error flag on parse failures.<br>
> - void visitSymbolStream(ArrayRef<uint8_t> Data) {<br>
> - for (const auto &I : makeSymbolRange(Data, &HadError)) {<br>
> + void visitSymbolStream(const CVSymbolArray &Symbols) {<br>
> + for (const auto &I : Symbols) {<br>
> visitSymbolRecord(I);<br>
> if (hadError())<br>
> break;<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h Sat May 28 00:21:57 2016<br>
> @@ -10,11 +10,10 @@<br>
> #ifndef LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H<br>
> #define LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H<br>
><br>
> +#include "llvm/DebugInfo/CodeView/CVRecord.h"<br>
> #include "llvm/DebugInfo/CodeView/CodeView.h"<br>
> -#include "llvm/DebugInfo/CodeView/RecordIterator.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeIndex.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeRecord.h"<br>
> -#include "llvm/DebugInfo/CodeView/TypeStream.h"<br>
> #include "llvm/Support/ErrorOr.h"<br>
><br>
> namespace llvm {<br>
> @@ -81,8 +80,8 @@ public:<br>
> }<br>
><br>
> /// Visits the type records in Data. Sets the error flag on parse failures.<br>
> - void visitTypeStream(ArrayRef<uint8_t> Data) {<br>
> - for (const auto &I : makeTypeRange(Data, &HadError)) {<br>
> + void visitTypeStream(const CVTypeArray &Types) {<br>
> + for (const auto &I : Types) {<br>
> visitTypeRecord(I);<br>
> if (hadError())<br>
> break;<br>
><br>
> Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/RecordIterator.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/RecordIterator.h?rev=271100&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/RecordIterator.h?rev=271100&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/RecordIterator.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/RecordIterator.h (removed)<br>
> @@ -1,143 +0,0 @@<br>
> -//===- RecordIterator.h -----------------------------------------*- C++ -*-===//<br>
> -//<br>
> -// The LLVM Compiler Infrastructure<br>
> -//<br>
> -// This file is distributed under the University of Illinois Open Source<br>
> -// License. See LICENSE.TXT for details.<br>
> -//<br>
> -//===----------------------------------------------------------------------===//<br>
> -<br>
> -#ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H<br>
> -#define LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H<br>
> -<br>
> -#include "llvm/ADT/ArrayRef.h"<br>
> -#include "llvm/ADT/iterator_range.h"<br>
> -#include "llvm/DebugInfo/CodeView/RecordSerialization.h"<br>
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"<br>
> -#include "llvm/DebugInfo/CodeView/StreamReader.h"<br>
> -#include "llvm/Support/Endian.h"<br>
> -<br>
> -namespace llvm {<br>
> -namespace codeview {<br>
> -<br>
> -template <typename Kind> struct CVRecord {<br>
> - uint32_t Length;<br>
> - Kind Type;<br>
> - ArrayRef<uint8_t> Data;<br>
> -};<br>
> -<br>
> -template <typename Kind> struct VarStreamArrayExtractor<CVRecord<Kind>> {<br>
> - uint32_t operator()(const StreamInterface &Stream,<br>
> - CVRecord<Kind> &Item) const {<br>
> - const RecordPrefix *Prefix = nullptr;<br>
> - StreamReader Reader(Stream);<br>
> - if (auto EC = Reader.readObject(Prefix)) {<br>
> - consumeError(std::move(EC));<br>
> - return 0;<br>
> - }<br>
> - Item.Length = Prefix->RecordLen;<br>
> - Item.Type = static_cast<Kind>(uint16_t(Prefix->RecordKind));<br>
> - if (auto EC = Reader.readBytes(Item.Length - 2, Item.Data)) {<br>
> - consumeError(std::move(EC));<br>
> - return 0;<br>
> - }<br>
> - return Prefix->RecordLen + 2;<br>
> - }<br>
> -};<br>
> -<br>
> -// A const input iterator interface to the CodeView record stream.<br>
> -template <typename Kind> class RecordIterator {<br>
> -public:<br>
> -<br>
> - explicit RecordIterator(const ArrayRef<uint8_t> &RecordBytes, bool *HadError)<br>
> - : HadError(HadError), Data(RecordBytes), AtEnd(false) {<br>
> - next(); // Prime the pump<br>
> - }<br>
> -<br>
> - RecordIterator() : HadError(nullptr), AtEnd(true) {}<br>
> -<br>
> - // For iterators to compare equal, they must both point at the same record<br>
> - // in the same data stream, or they must both be at the end of a stream.<br>
> - friend bool operator==(const RecordIterator<Kind> &lhs,<br>
> - const RecordIterator<Kind> &rhs) {<br>
> - return (lhs.Data.begin() == rhs.Data.begin()) || (lhs.AtEnd && rhs.AtEnd);<br>
> - }<br>
> -<br>
> - friend bool operator!=(const RecordIterator<Kind> &lhs,<br>
> - const RecordIterator<Kind> &rhs) {<br>
> - return !(lhs == rhs);<br>
> - }<br>
> -<br>
> - const CVRecord<Kind> &operator*() const {<br>
> - assert(!AtEnd);<br>
> - return Current;<br>
> - }<br>
> -<br>
> - const CVRecord<Kind> *operator->() const {<br>
> - assert(!AtEnd);<br>
> - return &Current;<br>
> - }<br>
> -<br>
> - RecordIterator<Kind> &operator++() {<br>
> - next();<br>
> - return *this;<br>
> - }<br>
> -<br>
> - RecordIterator<Kind> operator++(int) {<br>
> - RecordIterator<Kind> Original = *this;<br>
> - ++*this;<br>
> - return Original;<br>
> - }<br>
> -<br>
> -private:<br>
> - void next() {<br>
> - assert(!AtEnd && "Attempted to advance more than one past the last rec");<br>
> - if (Data.empty()) {<br>
> - // We've advanced past the last record.<br>
> - AtEnd = true;<br>
> - return;<br>
> - }<br>
> -<br>
> - // FIXME: Use consumeObject when it deals in ArrayRef<uint8_t>.<br>
> - if (Data.size() < sizeof(RecordPrefix))<br>
> - return parseError();<br>
> - const auto *Rec = reinterpret_cast<const RecordPrefix *>(Data.data());<br>
> - Data = Data.drop_front(sizeof(RecordPrefix));<br>
> -<br>
> - Current.Length = Rec->RecordLen;<br>
> - Current.Type = static_cast<Kind>(uint16_t(Rec->RecordKind));<br>
> - size_t RecLen = Current.Length - 2;<br>
> - if (RecLen > Data.size())<br>
> - return parseError();<br>
> - Current.Data = Data.slice(0, RecLen);<br>
> -<br>
> - // The next record starts immediately after this one.<br>
> - Data = Data.drop_front(Current.Data.size());<br>
> -<br>
> - // FIXME: The stream contains LF_PAD bytes that we need to ignore, but those<br>
> - // are typically included in LeafData. We may need to call skipPadding() if<br>
> - // we ever find a record that doesn't count those bytes.<br>
> -<br>
> - return;<br>
> - }<br>
> -<br>
> - void parseError() {<br>
> - if (HadError)<br>
> - *HadError = true;<br>
> - }<br>
> -<br>
> - bool *HadError;<br>
> - ArrayRef<uint8_t> Data;<br>
> - CVRecord<Kind> Current;<br>
> - bool AtEnd;<br>
> -};<br>
> -<br>
> -template <typename Kind><br>
> -inline iterator_range<RecordIterator<Kind>><br>
> -makeRecordRange(ArrayRef<uint8_t> Data, bool *HadError) {<br>
> - return make_range(RecordIterator<Kind>(Data, HadError), RecordIterator<Kind>());<br>
> -}<br>
> -}<br>
> -}<br>
> -<br>
> -#endif<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h Sat May 28 00:21:57 2016<br>
> @@ -11,6 +11,7 @@<br>
> #define LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H<br>
><br>
> #include "llvm/DebugInfo/CodeView/StreamRef.h"<br>
> +#include "llvm/Support/Error.h"<br>
><br>
> #include <functional><br>
> #include <type_traits><br>
> @@ -25,8 +26,11 @@ namespace codeview {<br>
> /// value type.<br>
> template <typename T> struct VarStreamArrayExtractor {<br>
> // Method intentionally deleted. You must provide an explicit specialization<br>
> - // with the following method implemented.<br>
> - uint32_t operator()(const StreamInterface &Stream, T &t) const = delete;<br>
> + // with the following method implemented. On output return `Len` should<br>
> + // contain the number of bytes to consume from the stream, and `Item` should<br>
> + // be initialized with the proper value.<br>
> + Error operator()(const StreamInterface &Stream, uint32_t &Len,<br>
> + T &Item) const = delete;<br>
> };<br>
><br>
> /// VarStreamArray represents an array of variable length records backed by a<br>
> @@ -52,7 +56,9 @@ public:<br>
><br>
> VarStreamArray(StreamRef Stream) : Stream(Stream) {}<br>
><br>
> - Iterator begin() const { return Iterator(*this); }<br>
> + Iterator begin(bool *HadError = nullptr) const {<br>
> + return Iterator(*this, HadError);<br>
> + }<br>
><br>
> Iterator end() const { return Iterator(); }<br>
><br>
> @@ -65,11 +71,20 @@ template <typename ValueType, typename E<br>
> typedef VarStreamArray<ValueType, Extractor> ArrayType;<br>
><br>
> public:<br>
> - VarStreamArrayIterator(const ArrayType &Array)<br>
> - : Array(&Array), IterRef(Array.Stream) {<br>
> - ThisLen = Extract(IterRef, ThisValue);<br>
> + VarStreamArrayIterator(const ArrayType &Array, bool *HadError = nullptr)<br>
> + : Array(&Array), IterRef(Array.Stream), HasError(false),<br>
> + HadError(HadError) {<br>
> + auto EC = Extract(IterRef, ThisLen, ThisValue);<br>
> + if (EC) {<br>
> + consumeError(std::move(EC));<br>
> + HasError = true;<br>
> + if (HadError)<br>
> + *HadError = true;<br>
> + }<br>
> }<br>
> - VarStreamArrayIterator() : Array(nullptr), IterRef() {}<br>
> + VarStreamArrayIterator() : Array(nullptr), IterRef(), HasError(false) {}<br>
> + ~VarStreamArrayIterator() {}<br>
> +<br>
> bool operator==(const IterType &R) const {<br>
> if (Array && R.Array) {<br>
> // Both have a valid array, make sure they're same.<br>
> @@ -87,19 +102,30 @@ public:<br>
><br>
> bool operator!=(const IterType &R) { return !(*this == R); }<br>
><br>
> - const ValueType &operator*() const { return ThisValue; }<br>
> + const ValueType &operator*() const {<br>
> + assert(Array && !HasError);<br>
> + return ThisValue;<br>
> + }<br>
><br>
> IterType &operator++() {<br>
> - if (!Array || IterRef.getLength() == 0 || ThisLen == 0)<br>
> + if (!Array || IterRef.getLength() == 0 || ThisLen == 0 || HasError)<br>
> return *this;<br>
> IterRef = IterRef.drop_front(ThisLen);<br>
> if (IterRef.getLength() == 0)<br>
> ThisLen = 0;<br>
> - else<br>
> - // TODO: We should report an error if Extract fails.<br>
> - ThisLen = Extract(IterRef, ThisValue);<br>
> - if (ThisLen == 0)<br>
> + else {<br>
> + auto EC = Extract(IterRef, ThisLen, ThisValue);<br>
> + if (EC) {<br>
> + consumeError(std::move(EC));<br>
> + HasError = true;<br>
> + if (HadError)<br>
> + *HadError = true;<br>
> + }<br>
> + }<br>
> + if (ThisLen == 0 || HasError) {<br>
> Array = nullptr;<br>
> + ThisLen = 0;<br>
> + }<br>
> return *this;<br>
> }<br>
><br>
> @@ -114,6 +140,8 @@ private:<br>
> uint32_t ThisLen;<br>
> ValueType ThisValue;<br>
> StreamRef IterRef;<br>
> + bool HasError;<br>
> + bool *HadError;<br>
> Extractor Extract;<br>
> };<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h Sat May 28 00:21:57 2016<br>
> @@ -28,8 +28,6 @@ class StreamInterface {<br>
> public:<br>
> virtual ~StreamInterface() {}<br>
><br>
> - virtual Error readBytes(uint32_t Offset,<br>
> - MutableArrayRef<uint8_t> Buffer) const = 0;<br>
> virtual Error readBytes(uint32_t Offset, uint32_t Size,<br>
> ArrayRef<uint8_t> &Buffer) const = 0;<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h Sat May 28 00:21:57 2016<br>
> @@ -28,18 +28,17 @@ class StreamReader {<br>
> public:<br>
> StreamReader(const StreamInterface &S);<br>
><br>
> - Error readBytes(uint32_t Size, ArrayRef<uint8_t> &Buffer);<br>
> + Error readBytes(ArrayRef<uint8_t> &Buffer, uint32_t Size);<br>
> Error readInteger(uint16_t &Dest);<br>
> Error readInteger(uint32_t &Dest);<br>
> Error readZeroString(StringRef &Dest);<br>
> Error readFixedString(StringRef &Dest, uint32_t Length);<br>
> Error readStreamRef(StreamRef &Ref);<br>
> Error readStreamRef(StreamRef &Ref, uint32_t Length);<br>
> - Error readBytes(MutableArrayRef<uint8_t> Buffer);<br>
><br>
> template <typename T> Error readObject(const T *&Dest) {<br>
> ArrayRef<uint8_t> Buffer;<br>
> - if (auto EC = readBytes(sizeof(T), Buffer))<br>
> + if (auto EC = readBytes(Buffer, sizeof(T)))<br>
> return EC;<br>
> Dest = reinterpret_cast<const T *>(Buffer.data());<br>
> return Error::success();<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h Sat May 28 00:21:57 2016<br>
> @@ -26,11 +26,6 @@ public:<br>
> : Stream(Other.Stream), ViewOffset(Other.ViewOffset),<br>
> Length(Other.Length) {}<br>
><br>
> - Error readBytes(uint32_t Offset,<br>
> - MutableArrayRef<uint8_t> Buffer) const override {<br>
> - return Stream->readBytes(ViewOffset + Offset, Buffer);<br>
> - }<br>
> -<br>
> Error readBytes(uint32_t Offset, uint32_t Size,<br>
> ArrayRef<uint8_t> &Buffer) const override {<br>
> return Stream->readBytes(ViewOffset + Offset, Size, Buffer);<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDumper.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDumper.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDumper.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDumper.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDumper.h Sat May 28 00:21:57 2016<br>
> @@ -39,7 +39,7 @@ public:<br>
><br>
> /// Dumps the type records in Data. Returns false if there was a type stream<br>
> /// parse error, and true otherwise.<br>
> - bool dump(ArrayRef<uint8_t> Data);<br>
> + bool dump(const CVSymbolArray &Symbols);<br>
><br>
> private:<br>
> ScopedPrinter &W;<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h Sat May 28 00:21:57 2016<br>
> @@ -12,8 +12,8 @@<br>
><br>
> #include "llvm/ADT/APSInt.h"<br>
> #include "llvm/ADT/Optional.h"<br>
> +#include "llvm/DebugInfo/CodeView/CVRecord.h"<br>
> #include "llvm/DebugInfo/CodeView/CodeView.h"<br>
> -#include "llvm/DebugInfo/CodeView/RecordIterator.h"<br>
> #include "llvm/DebugInfo/CodeView/RecordSerialization.h"<br>
> #include "llvm/DebugInfo/CodeView/StreamArray.h"<br>
> #include "llvm/DebugInfo/CodeView/StreamInterface.h"<br>
> @@ -1442,15 +1442,9 @@ public:<br>
> StringRef Name;<br>
> };<br>
><br>
> -typedef RecordIterator<SymbolKind> SymbolIterator;<br>
> typedef CVRecord<SymbolKind> CVSymbol;<br>
> typedef VarStreamArray<CVSymbol> CVSymbolArray;<br>
><br>
> -inline iterator_range<SymbolIterator> makeSymbolRange(ArrayRef<uint8_t> Data,<br>
> - bool *HadError) {<br>
> - return make_range(SymbolIterator(Data, HadError), SymbolIterator());<br>
> -}<br>
> -<br>
> } // namespace codeview<br>
> } // namespace llvm<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeDumper.h Sat May 28 00:21:57 2016<br>
> @@ -14,7 +14,6 @@<br>
> #include "llvm/ADT/StringSet.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeIndex.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeRecord.h"<br>
> -#include "llvm/DebugInfo/CodeView/TypeStream.h"<br>
><br>
> namespace llvm {<br>
> class ScopedPrinter;<br>
> @@ -38,7 +37,7 @@ public:<br>
><br>
> /// Dumps the type records in Data. Returns false if there was a type stream<br>
> /// parse error, and true otherwise.<br>
> - bool dump(ArrayRef<uint8_t> Data);<br>
> + bool dump(const CVTypeArray &Types);<br>
><br>
> /// Gets the type index for the next type record.<br>
> unsigned getNextTypeIndex() const {<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h Sat May 28 00:21:57 2016<br>
> @@ -13,8 +13,10 @@<br>
> #include "llvm/ADT/APSInt.h"<br>
> #include "llvm/ADT/ArrayRef.h"<br>
> #include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/DebugInfo/CodeView/CVRecord.h"<br>
> #include "llvm/DebugInfo/CodeView/CodeView.h"<br>
> #include "llvm/DebugInfo/CodeView/RecordSerialization.h"<br>
> +#include "llvm/DebugInfo/CodeView/StreamArray.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeIndex.h"<br>
> #include "llvm/Support/ErrorOr.h"<br>
> #include <cinttypes><br>
> @@ -1398,6 +1400,9 @@ private:<br>
> uint64_t VBPtrOffset;<br>
> uint64_t VTableIndex;<br>
> };<br>
> +<br>
> +typedef CVRecord<TypeLeafKind> CVType;<br>
> +typedef VarStreamArray<CVType> CVTypeArray;<br>
> }<br>
> }<br>
><br>
><br>
> Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStream.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStream.h?rev=271100&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStream.h?rev=271100&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStream.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStream.h (removed)<br>
> @@ -1,37 +0,0 @@<br>
> -//===- TypeStream.h ---------------------------------------------*- C++ -*-===//<br>
> -//<br>
> -// The LLVM Compiler Infrastructure<br>
> -//<br>
> -// This file is distributed under the University of Illinois Open Source<br>
> -// License. See LICENSE.TXT for details.<br>
> -//<br>
> -//===----------------------------------------------------------------------===//<br>
> -<br>
> -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESTREAM_H<br>
> -#define LLVM_DEBUGINFO_CODEVIEW_TYPESTREAM_H<br>
> -<br>
> -#include "llvm/ADT/ArrayRef.h"<br>
> -#include "llvm/ADT/StringRef.h"<br>
> -#include "llvm/ADT/iterator_range.h"<br>
> -#include "llvm/DebugInfo/CodeView/RecordIterator.h"<br>
> -#include "llvm/DebugInfo/CodeView/TypeRecord.h"<br>
> -#include "llvm/Support/Endian.h"<br>
> -#include <cstdint><br>
> -#include <system_error><br>
> -<br>
> -namespace llvm {<br>
> -<br>
> -class APSInt;<br>
> -<br>
> -namespace codeview {<br>
> -<br>
> -typedef RecordIterator<TypeLeafKind> TypeIterator;<br>
> -<br>
> -inline iterator_range<TypeIterator> makeTypeRange(ArrayRef<uint8_t> Data, bool *HadError) {<br>
> - return make_range(TypeIterator(Data, HadError), TypeIterator());<br>
> -}<br>
> -<br>
> -} // end namespace codeview<br>
> -} // end namespace llvm<br>
> -<br>
> -#endif // LLVM_DEBUGINFO_CODEVIEW_TYPESTREAM_H<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h Sat May 28 00:21:57 2016<br>
> @@ -18,8 +18,7 @@ namespace llvm {<br>
> namespace codeview {<br>
><br>
> /// Merges one type stream into another. Returns true on success.<br>
> -bool mergeTypeStreams(TypeTableBuilder &DestStream,<br>
> - ArrayRef<uint8_t> SrcStream);<br>
> +bool mergeTypeStreams(TypeTableBuilder &DestStream, const CVTypeArray &Types);<br>
><br>
> } // end namespace codeview<br>
> } // end namespace llvm<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h Sat May 28 00:21:57 2016<br>
> @@ -27,14 +27,13 @@ class MappedBlockStream : public codevie<br>
> public:<br>
> MappedBlockStream(uint32_t StreamIdx, const PDBFile &File);<br>
><br>
> - Error readBytes(uint32_t Offset,<br>
> - MutableArrayRef<uint8_t> Buffer) const override;<br>
> Error readBytes(uint32_t Offset, uint32_t Size,<br>
> ArrayRef<uint8_t> &Buffer) const override;<br>
><br>
> uint32_t getLength() const override { return StreamLength; }<br>
><br>
> private:<br>
> + Error readBytes(uint32_t Offset, MutableArrayRef<uint8_t> Buffer) const;<br>
> bool tryReadContiguously(uint32_t Offset, uint32_t Size,<br>
> ArrayRef<uint8_t> &Buffer) const;<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h Sat May 28 00:21:57 2016<br>
> @@ -25,10 +25,11 @@ private:<br>
><br>
> public:<br>
> ModInfo();<br>
> - ModInfo(codeview::StreamRef Stream);<br>
> ModInfo(const ModInfo &Info);<br>
> ~ModInfo();<br>
><br>
> + static Error initialize(codeview::StreamRef Stream, ModInfo &Info);<br>
> +<br>
> bool hasECInfo() const;<br>
> uint16_t getTypeServerIndex() const;<br>
> uint16_t getModuleStreamIndex() const;<br>
> @@ -51,7 +52,6 @@ private:<br>
> };<br>
><br>
> struct ModuleInfoEx {<br>
> - ModuleInfoEx(codeview::StreamRef Stream) : Info(Stream) {}<br>
> ModuleInfoEx(const ModInfo &Info) : Info(Info) {}<br>
> ModuleInfoEx(const ModuleInfoEx &Ex)<br>
> : Info(Ex.Info), SourceFiles(Ex.SourceFiles) {}<br>
> @@ -64,9 +64,12 @@ struct ModuleInfoEx {<br>
><br>
> namespace codeview {<br>
> template <> struct VarStreamArrayExtractor<pdb::ModInfo> {<br>
> - uint32_t operator()(const StreamInterface &Stream, pdb::ModInfo &Info) const {<br>
> - Info = pdb::ModInfo(Stream);<br>
> - return Info.getRecordLength();<br>
> + Error operator()(const StreamInterface &Stream, uint32_t &Length,<br>
> + pdb::ModInfo &Info) const {<br>
> + if (auto EC = pdb::ModInfo::initialize(Stream, Info))<br>
> + return EC;<br>
> + Length = Info.getRecordLength();<br>
> + return Error::success();<br>
> }<br>
> };<br>
> }<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h Sat May 28 00:21:57 2016<br>
> @@ -11,7 +11,7 @@<br>
> #define LLVM_DEBUGINFO_PDB_RAW_MODSTREAM_H<br>
><br>
> #include "llvm/ADT/iterator_range.h"<br>
> -#include "llvm/DebugInfo/CodeView/RecordIterator.h"<br>
> +#include "llvm/DebugInfo/CodeView/CVRecord.h"<br>
> #include "llvm/DebugInfo/CodeView/StreamRef.h"<br>
> #include "llvm/DebugInfo/CodeView/SymbolRecord.h"<br>
> #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"<br>
> @@ -29,7 +29,8 @@ public:<br>
><br>
> Error reload();<br>
><br>
> - iterator_range<codeview::CVSymbolArray::Iterator> symbols() const;<br>
> + iterator_range<codeview::CVSymbolArray::Iterator><br>
> + symbols(bool *HadError) const;<br>
><br>
> private:<br>
> const ModInfo &Mod;<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h Sat May 28 00:21:57 2016<br>
> @@ -12,7 +12,6 @@<br>
><br>
> #include "llvm/DebugInfo/CodeView/StreamArray.h"<br>
> #include "llvm/DebugInfo/CodeView/SymbolRecord.h"<br>
> -#include "llvm/DebugInfo/CodeView/TypeStream.h"<br>
> #include "llvm/DebugInfo/PDB/PDBTypes.h"<br>
> #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"<br>
> #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"<br>
> @@ -37,7 +36,8 @@ public:<br>
> uint32_t getSymHash() const;<br>
> uint32_t getAddrMap() const;<br>
> uint32_t getNumBuckets() const { return NumBuckets; }<br>
> - iterator_range<codeview::SymbolIterator> getSymbols() const;<br>
> + iterator_range<codeview::CVSymbolArray::Iterator><br>
> + getSymbols(bool *HadError) const;<br>
> codeview::FixedStreamArray<support::ulittle32_t> getHashBuckets() const {<br>
> return HashBuckets;<br>
> }<br>
> @@ -52,8 +52,6 @@ public:<br>
> }<br>
><br>
> private:<br>
> - Error readSymbols();<br>
> -<br>
> PDBFile &Pdb;<br>
><br>
> uint32_t StreamNum;<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h Sat May 28 00:21:57 2016<br>
> @@ -10,7 +10,7 @@<br>
> #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H<br>
> #define LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H<br>
><br>
> -#include "llvm/DebugInfo/CodeView/ByteStream.h"<br>
> +#include "llvm/DebugInfo/CodeView/StreamArray.h"<br>
> #include "llvm/DebugInfo/CodeView/SymbolRecord.h"<br>
> #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"<br>
><br>
> @@ -26,10 +26,11 @@ public:<br>
> ~SymbolStream();<br>
> Error reload();<br>
><br>
> - iterator_range<codeview::SymbolIterator> getSymbols() const;<br>
> + iterator_range<codeview::CVSymbolArray::Iterator><br>
> + getSymbols(bool *HadError) const;<br>
><br>
> private:<br>
> - codeview::ByteStream Stream;<br>
> + codeview::CVSymbolArray SymbolRecords;<br>
> MappedBlockStream MappedStream;<br>
> };<br>
> }<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h Sat May 28 00:21:57 2016<br>
> @@ -10,9 +10,9 @@<br>
> #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H<br>
> #define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H<br>
><br>
> -#include "llvm/DebugInfo/CodeView/ByteStream.h"<br>
> +#include "llvm/DebugInfo/CodeView/StreamArray.h"<br>
> #include "llvm/DebugInfo/CodeView/StreamRef.h"<br>
> -#include "llvm/DebugInfo/CodeView/TypeStream.h"<br>
> +#include "llvm/DebugInfo/CodeView/TypeRecord.h"<br>
> #include "llvm/DebugInfo/PDB/PDBTypes.h"<br>
> #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"<br>
> #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"<br>
> @@ -41,14 +41,14 @@ public:<br>
> uint16_t getTypeHashStreamIndex() const;<br>
> uint16_t getTypeHashStreamAuxIndex() const;<br>
><br>
> - iterator_range<codeview::TypeIterator> types(bool *HadError) const;<br>
> + iterator_range<codeview::CVTypeArray::Iterator> types(bool *HadError) const;<br>
><br>
> private:<br>
> PDBFile &Pdb;<br>
> MappedBlockStream Stream;<br>
> HashFunctionType HashFunction;<br>
><br>
> - codeview::ByteStream RecordsBuffer;<br>
> + codeview::CVTypeArray TypeRecords;<br>
> codeview::StreamRef TypeIndexOffsetBuffer;<br>
> codeview::StreamRef HashValuesBuffer;<br>
> codeview::StreamRef HashAdjBuffer;<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp Sat May 28 00:21:57 2016<br>
> @@ -17,41 +17,13 @@ using namespace llvm::codeview;<br>
><br>
> ByteStream::ByteStream() {}<br>
><br>
> -ByteStream::ByteStream(MutableArrayRef<uint8_t> Data) : Data(Data) {}<br>
> +ByteStream::ByteStream(ArrayRef<uint8_t> Data) : Data(Data) {}<br>
><br>
> ByteStream::~ByteStream() {}<br>
><br>
> -void ByteStream::reset() {<br>
> - Ownership.reset();<br>
> - Data = MutableArrayRef<uint8_t>();<br>
> -}<br>
> -<br>
> -void ByteStream::load(uint32_t Length) {<br>
> - reset();<br>
> - if (Length > 0)<br>
> - Data = MutableArrayRef<uint8_t>(new uint8_t[Length], Length);<br>
> - Ownership.reset(Data.data());<br>
> -}<br>
> -<br>
> -Error ByteStream::load(StreamReader &Reader, uint32_t Length) {<br>
> - load(Length);<br>
> - auto EC = Reader.readBytes(Data);<br>
> - if (EC)<br>
> - reset();<br>
> - return EC;<br>
> -}<br>
> -<br>
> -Error ByteStream::readBytes(uint32_t Offset,<br>
> - MutableArrayRef<uint8_t> Buffer) const {<br>
> - if (Data.size() < Buffer.size() + Offset)<br>
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);<br>
> - ::memcpy(Buffer.data() + Offset, Data.data(), Buffer.size());<br>
> - return Error::success();<br>
> -}<br>
> -<br>
> Error ByteStream::readBytes(uint32_t Offset, uint32_t Size,<br>
> ArrayRef<uint8_t> &Buffer) const {<br>
> - if (Data.size() < Buffer.size() + Offset)<br>
> + if (Data.size() < Size + Offset)<br>
> return make_error<CodeViewError>(cv_error_code::insufficient_buffer);<br>
> Buffer = Data.slice(Offset, Size);<br>
> return Error::success();<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp Sat May 28 00:21:57 2016<br>
> @@ -17,20 +17,13 @@ using namespace llvm::codeview;<br>
><br>
> StreamReader::StreamReader(const StreamInterface &S) : Stream(S), Offset(0) {}<br>
><br>
> -Error StreamReader::readBytes(uint32_t Size, ArrayRef<uint8_t> &Buffer) {<br>
> +Error StreamReader::readBytes(ArrayRef<uint8_t> &Buffer, uint32_t Size) {<br>
> if (auto EC = Stream.readBytes(Offset, Size, Buffer))<br>
> return EC;<br>
> Offset += Size;<br>
> return Error::success();<br>
> }<br>
><br>
> -Error StreamReader::readBytes(MutableArrayRef<uint8_t> Buffer) {<br>
> - if (auto EC = Stream.readBytes(Offset, Buffer))<br>
> - return EC;<br>
> - Offset += Buffer.size();<br>
> - return Error::success();<br>
> -}<br>
> -<br>
> Error StreamReader::readInteger(uint16_t &Dest) {<br>
> const support::ulittle16_t *P;<br>
> if (auto EC = readObject(P))<br>
> @@ -63,7 +56,7 @@ Error StreamReader::readZeroString(Strin<br>
> setOffset(OriginalOffset);<br>
><br>
> ArrayRef<uint8_t> Data;<br>
> - if (auto EC = readBytes(Length, Data))<br>
> + if (auto EC = readBytes(Data, Length))<br>
> return EC;<br>
> Dest = StringRef(reinterpret_cast<const char *>(Data.begin()), Data.size());<br>
><br>
> @@ -74,7 +67,7 @@ Error StreamReader::readZeroString(Strin<br>
><br>
> Error StreamReader::readFixedString(StringRef &Dest, uint32_t Length) {<br>
> ArrayRef<uint8_t> Bytes;<br>
> - if (auto EC = readBytes(Length, Bytes))<br>
> + if (auto EC = readBytes(Bytes, Length))<br>
> return EC;<br>
> Dest = StringRef(reinterpret_cast<const char *>(Bytes.begin()), Bytes.size());<br>
> return Error::success();<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp Sat May 28 00:21:57 2016<br>
> @@ -872,8 +872,8 @@ bool CVSymbolDumper::dump(const CVRecord<br>
> return !Dumper.hadError();<br>
> }<br>
><br>
> -bool CVSymbolDumper::dump(ArrayRef<uint8_t> Data) {<br>
> +bool CVSymbolDumper::dump(const CVSymbolArray &Symbols) {<br>
> CVSymbolDumperImpl Dumper(CVTD, ObjDelegate.get(), W, PrintRecordBytes);<br>
> - Dumper.visitSymbolStream(Data);<br>
> + Dumper.visitSymbolStream(Symbols);<br>
> return !Dumper.hadError();<br>
> }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp Sat May 28 00:21:57 2016<br>
> @@ -12,7 +12,6 @@<br>
> #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeIndex.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeRecord.h"<br>
> -#include "llvm/DebugInfo/CodeView/TypeStream.h"<br>
> #include "llvm/Support/ScopedPrinter.h"<br>
><br>
> using namespace llvm;<br>
> @@ -683,10 +682,10 @@ bool CVTypeDumper::dump(const CVRecord<T<br>
> return !Dumper.hadError();<br>
> }<br>
><br>
> -bool CVTypeDumper::dump(ArrayRef<uint8_t> Data) {<br>
> +bool CVTypeDumper::dump(const CVTypeArray &Types) {<br>
> assert(W && "printer should not be null");<br>
> CVTypeDumperImpl Dumper(*this, *W, PrintRecordBytes);<br>
> - Dumper.visitTypeStream(Data);<br>
> + Dumper.visitTypeStream(Types);<br>
> return !Dumper.hadError();<br>
> }<br>
><br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp Sat May 28 00:21:57 2016<br>
> @@ -12,9 +12,9 @@<br>
> #include "llvm/ADT/StringExtras.h"<br>
> #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"<br>
> #include "llvm/DebugInfo/CodeView/FieldListRecordBuilder.h"<br>
> +#include "llvm/DebugInfo/CodeView/StreamRef.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeIndex.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeRecord.h"<br>
> -#include "llvm/DebugInfo/CodeView/TypeStream.h"<br>
> #include "llvm/Support/ScopedPrinter.h"<br>
><br>
> using namespace llvm;<br>
> @@ -71,7 +71,7 @@ public:<br>
><br>
> void visitFieldList(TypeLeafKind Leaf, ArrayRef<uint8_t> FieldData);<br>
><br>
> - bool mergeStream(ArrayRef<uint8_t> SrcStream);<br>
> + bool mergeStream(const CVTypeArray &Types);<br>
><br>
> private:<br>
> bool hadError() { return FoundBadTypeIndex || CVTypeVisitor::hadError(); }<br>
> @@ -131,14 +131,14 @@ void TypeStreamMerger::visitUnknownMembe<br>
> parseError();<br>
> }<br>
><br>
> -bool TypeStreamMerger::mergeStream(ArrayRef<uint8_t> SrcStream) {<br>
> +bool TypeStreamMerger::mergeStream(const CVTypeArray &Types) {<br>
> assert(IndexMap.empty());<br>
> - visitTypeStream(SrcStream);<br>
> + visitTypeStream(Types);<br>
> IndexMap.clear();<br>
> return !hadError();<br>
> }<br>
><br>
> bool llvm::codeview::mergeTypeStreams(TypeTableBuilder &DestStream,<br>
> - ArrayRef<uint8_t> SrcStream) {<br>
> - return TypeStreamMerger(DestStream).mergeStream(SrcStream);<br>
> + const CVTypeArray &Types) {<br>
> + return TypeStreamMerger(DestStream).mergeStream(Types);<br>
> }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp Sat May 28 00:21:57 2016<br>
> @@ -69,28 +69,25 @@ struct ModInfo::FileLayout {<br>
><br>
> ModInfo::ModInfo() : Layout(nullptr) {}<br>
><br>
> -ModInfo::ModInfo(codeview::StreamRef Stream) : Layout(nullptr) {<br>
> - codeview::StreamReader Reader(Stream);<br>
> - if (auto EC = Reader.readObject(Layout)) {<br>
> - consumeError(std::move(EC));<br>
> - return;<br>
> - }<br>
> - if (auto EC = Reader.readZeroString(ModuleName)) {<br>
> - consumeError(std::move(EC));<br>
> - return;<br>
> - }<br>
> - if (auto EC = Reader.readZeroString(ObjFileName)) {<br>
> - consumeError(std::move(EC));<br>
> - return;<br>
> - }<br>
> -}<br>
> -<br>
> ModInfo::ModInfo(const ModInfo &Info)<br>
> : ModuleName(Info.ModuleName), ObjFileName(Info.ObjFileName),<br>
> Layout(Info.Layout) {}<br>
><br>
> ModInfo::~ModInfo() {}<br>
><br>
> +Error ModInfo::initialize(codeview::StreamRef Stream, ModInfo &Info) {<br>
> + codeview::StreamReader Reader(Stream);<br>
> + if (auto EC = Reader.readObject(Info.Layout))<br>
> + return EC;<br>
> +<br>
> + if (auto EC = Reader.readZeroString(Info.ModuleName))<br>
> + return EC;<br>
> +<br>
> + if (auto EC = Reader.readZeroString(Info.ObjFileName))<br>
> + return EC;<br>
> + return Error::success();<br>
> +}<br>
> +<br>
> bool ModInfo::hasECInfo() const { return (Layout->Flags & HasECFlagMask) != 0; }<br>
><br>
> uint16_t ModInfo::getTypeServerIndex() const {<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp Sat May 28 00:21:57 2016<br>
> @@ -9,7 +9,6 @@<br>
><br>
> #include "llvm/DebugInfo/PDB/Raw/ModStream.h"<br>
><br>
> -#include "llvm/DebugInfo/CodeView/RecordIterator.h"<br>
> #include "llvm/DebugInfo/CodeView/StreamReader.h"<br>
> #include "llvm/DebugInfo/PDB/Raw/ModInfo.h"<br>
> #include "llvm/DebugInfo/PDB/Raw/RawError.h"<br>
> @@ -58,6 +57,7 @@ Error ModStream::reload() {<br>
> return Error::success();<br>
> }<br>
><br>
> -iterator_range<codeview::CVSymbolArray::Iterator> ModStream::symbols() const {<br>
> +iterator_range<codeview::CVSymbolArray::Iterator><br>
> +ModStream::symbols(bool *HadError) const {<br>
> return llvm::make_range(SymbolsSubstream.begin(), SymbolsSubstream.end());<br>
> }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp Sat May 28 00:21:57 2016<br>
> @@ -113,7 +113,7 @@ Error PublicsStream::reload() {<br>
> // A bitmap of a fixed length follows.<br>
> size_t BitmapSizeInBits = alignTo(IPHR_HASH + 1, 32);<br>
> uint32_t NumBitmapEntries = BitmapSizeInBits / 8;<br>
> - if (auto EC = Reader.readBytes(NumBitmapEntries, Bitmap))<br>
> + if (auto EC = Reader.readBytes(Bitmap, NumBitmapEntries))<br>
> return joinErrors(std::move(EC),<br>
> make_error<RawError>(raw_error_code::corrupt_file,<br>
> "Could not read a bitmap."));<br>
> @@ -156,13 +156,14 @@ Error PublicsStream::reload() {<br>
> return Error::success();<br>
> }<br>
><br>
> -iterator_range<codeview::SymbolIterator> PublicsStream::getSymbols() const {<br>
> - using codeview::SymbolIterator;<br>
> +iterator_range<codeview::CVSymbolArray::Iterator><br>
> +PublicsStream::getSymbols(bool *HadError) const {<br>
> auto SymbolS = Pdb.getPDBSymbolStream();<br>
> if (SymbolS.takeError()) {<br>
> - return llvm::make_range<SymbolIterator>(SymbolIterator(), SymbolIterator());<br>
> + codeview::CVSymbolArray::Iterator Iter;<br>
<br>
Coverity complains about:<br>
>>> CID 1356134: Memory - illegal accesses (UNINIT)<br>
>>> Declaring variable "Iter".<br>
<br>
--<br>
Mehdi<br>
<br>
<br>
<br>
> + return llvm::make_range(Iter, Iter);<br>
> }<br>
> SymbolStream &SS = SymbolS.get();<br>
><br>
> - return SS.getSymbols();<br>
> + return SS.getSymbols(HadError);<br>
> }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp Sat May 28 00:21:57 2016<br>
> @@ -30,20 +30,13 @@ SymbolStream::~SymbolStream() {}<br>
> Error SymbolStream::reload() {<br>
> codeview::StreamReader Reader(MappedStream);<br>
><br>
> - if (Stream.load(Reader, MappedStream.getLength()))<br>
> - return make_error<RawError>(raw_error_code::corrupt_file,<br>
> - "Could not load symbol stream.");<br>
> + if (auto EC = Reader.readArray(SymbolRecords, MappedStream.getLength()))<br>
> + return EC;<br>
><br>
> return Error::success();<br>
> }<br>
><br>
> -iterator_range<codeview::SymbolIterator> SymbolStream::getSymbols() const {<br>
> - using codeview::SymbolIterator;<br>
> - ArrayRef<uint8_t> Data;<br>
> - if (auto Error = Stream.readBytes(0, Stream.getLength(), Data)) {<br>
> - consumeError(std::move(Error));<br>
> - return iterator_range<SymbolIterator>(SymbolIterator(), SymbolIterator());<br>
> - }<br>
> -<br>
> - return codeview::makeSymbolRange(Data, nullptr);<br>
> +iterator_range<codeview::CVSymbolArray::Iterator><br>
> +SymbolStream::getSymbols(bool *HadError) const {<br>
> + return llvm::make_range(SymbolRecords.begin(HadError), SymbolRecords.end());<br>
> }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp Sat May 28 00:21:57 2016<br>
> @@ -92,7 +92,7 @@ Error TpiStream::reload() {<br>
> HashFunction = HashBufferV8;<br>
><br>
> // The actual type records themselves come from this stream<br>
> - if (auto EC = RecordsBuffer.load(Reader, Header->TypeRecordBytes))<br>
> + if (auto EC = Reader.readArray(TypeRecords, Header->TypeRecordBytes))<br>
> return EC;<br>
><br>
> // Hash indices, hash values, etc come from the hash stream.<br>
> @@ -136,6 +136,7 @@ uint16_t TpiStream::getTypeHashStreamAux<br>
> return Header->HashAuxStreamIndex;<br>
> }<br>
><br>
> -iterator_range<codeview::TypeIterator> TpiStream::types(bool *HadError) const {<br>
> - return codeview::makeTypeRange(RecordsBuffer.data(), /*HadError=*/HadError);<br>
> +iterator_range<codeview::CVTypeArray::Iterator><br>
> +TpiStream::types(bool *HadError) const {<br>
> + return llvm::make_range(TypeRecords.begin(HadError), TypeRecords.end());<br>
> }<br>
><br>
> Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Sat May 28 00:21:57 2016<br>
> @@ -354,7 +354,7 @@ static Error dumpStreamData(ScopedPrinte<br>
> ArrayRef<uint8_t> Data;<br>
> uint32_t BytesToReadInBlock = std::min(<br>
> R.bytesRemaining(), static_cast<uint32_t>(File.getBlockSize()));<br>
> - if (auto EC = R.readBytes(BytesToReadInBlock, Data))<br>
> + if (auto EC = R.readBytes(Data, BytesToReadInBlock))<br>
> return EC;<br>
> P.printBinaryBlock(<br>
> "Data",<br>
> @@ -485,7 +485,8 @@ static Error dumpDbiStream(ScopedPrinter<br>
> return EC;<br>
><br>
> codeview::CVSymbolDumper SD(P, TD, nullptr, false);<br>
> - for (auto &S : ModS.symbols()) {<br>
> + bool HadError = false;<br>
> + for (auto &S : ModS.symbols(&HadError)) {<br>
> DictScope DD(P, "");<br>
><br>
> if (opts::DumpModuleSyms)<br>
> @@ -493,6 +494,9 @@ static Error dumpDbiStream(ScopedPrinter<br>
> if (opts::DumpSymRecordBytes)<br>
> P.printBinaryBlock("Bytes", S.Data);<br>
> }<br>
> + if (HadError)<br>
> + return make_error<RawError>(raw_error_code::corrupt_file,<br>
> + "DBI stream contained corrupt record");<br>
> }<br>
> }<br>
> }<br>
> @@ -509,7 +513,7 @@ static Error dumpTpiStream(ScopedPrinter<br>
> StringRef VerLabel;<br>
> if (StreamIdx == StreamTPI) {<br>
> DumpRecordBytes = opts::DumpTpiRecordBytes;<br>
> - DumpRecords = opts::DumpTpiRecordBytes;<br>
> + DumpRecords = opts::DumpTpiRecords;<br>
> Label = "Type Info Stream (TPI)";<br>
> VerLabel = "TPI Version";<br>
> } else if (StreamIdx == StreamIPI) {<br>
> @@ -595,13 +599,19 @@ static Error dumpPublicsStream(ScopedPri<br>
> printSectionOffset);<br>
> ListScope L(P, "Symbols");<br>
> codeview::CVSymbolDumper SD(P, TD, nullptr, false);<br>
> - for (auto S : Publics.getSymbols()) {<br>
> + bool HadError = false;<br>
> + for (auto S : Publics.getSymbols(&HadError)) {<br>
> DictScope DD(P, "");<br>
><br>
> SD.dump(S);<br>
> if (opts::DumpSymRecordBytes)<br>
> P.printBinaryBlock("Bytes", S.Data);<br>
> }<br>
> + if (HadError)<br>
> + return make_error<RawError>(<br>
> + raw_error_code::corrupt_file,<br>
> + "Public symbol stream contained corrupt record");<br>
> +<br>
> return Error::success();<br>
> }<br>
><br>
><br>
> Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=271101&r1=271100&r2=271101&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=271101&r1=271100&r2=271101&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Sat May 28 00:21:57 2016<br>
> @@ -22,6 +22,7 @@<br>
> #include "llvm/ADT/DenseMap.h"<br>
> #include "llvm/ADT/SmallString.h"<br>
> #include "llvm/ADT/StringExtras.h"<br>
> +#include "llvm/DebugInfo/CodeView/ByteStream.h"<br>
> #include "llvm/DebugInfo/CodeView/CodeView.h"<br>
> #include "llvm/DebugInfo/CodeView/Line.h"<br>
> #include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h"<br>
> @@ -32,7 +33,6 @@<br>
> #include "llvm/DebugInfo/CodeView/TypeDumper.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeIndex.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeRecord.h"<br>
> -#include "llvm/DebugInfo/CodeView/TypeStream.h"<br>
> #include "llvm/DebugInfo/CodeView/TypeStreamMerger.h"<br>
> #include "llvm/Object/COFF.h"<br>
> #include "llvm/Object/ObjectFile.h"<br>
> @@ -898,8 +898,16 @@ void COFFDumper::printCodeViewSymbolsSub<br>
> SectionContents);<br>
><br>
> CVSymbolDumper CVSD(W, CVTD, std::move(CODD), opts::CodeViewSubsectionBytes);<br>
> + ByteStream Stream(BinaryData);<br>
> + CVSymbolArray Symbols;<br>
> + StreamReader Reader(Stream);<br>
> + if (auto EC = Reader.readArray(Symbols, Reader.getLength())) {<br>
> + consumeError(std::move(EC));<br>
> + W.flush();<br>
> + error(object_error::parse_failed);<br>
> + }<br>
><br>
> - if (!CVSD.dump(BinaryData)) {<br>
> + if (!CVSD.dump(Symbols)) {<br>
> W.flush();<br>
> error(object_error::parse_failed);<br>
> }<br>
> @@ -996,7 +1004,16 @@ void COFFDumper::mergeCodeViewTypes(Memo<br>
> Data = Data.drop_front(4);<br>
> ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(Data.data()),<br>
> Data.size());<br>
> - if (!mergeTypeStreams(CVTypes, Bytes))<br>
> + ByteStream Stream(Bytes);<br>
> + CVTypeArray Types;<br>
> + StreamReader Reader(Stream);<br>
> + if (auto EC = Reader.readArray(Types, Reader.getLength())) {<br>
> + consumeError(std::move(EC));<br>
> + W.flush();<br>
> + error(object_error::parse_failed);<br>
> + }<br>
> +<br>
> + if (!mergeTypeStreams(CVTypes, Types))<br>
> return error(object_error::parse_failed);<br>
> }<br>
> }<br>
> @@ -1020,7 +1037,16 @@ void COFFDumper::printCodeViewTypeSectio<br>
><br>
> ArrayRef<uint8_t> BinaryData(reinterpret_cast<const uint8_t *>(Data.data()),<br>
> Data.size());<br>
> - if (!CVTD.dump(BinaryData)) {<br>
> + ByteStream Stream(BinaryData);<br>
> + CVTypeArray Types;<br>
> + StreamReader Reader(Stream);<br>
> + if (auto EC = Reader.readArray(Types, Reader.getLength())) {<br>
> + consumeError(std::move(EC));<br>
> + W.flush();<br>
> + error(object_error::parse_failed);<br>
> + }<br>
> +<br>
> + if (!CVTD.dump(Types)) {<br>
> W.flush();<br>
> error(object_error::parse_failed);<br>
> }<br>
> @@ -1472,7 +1498,16 @@ void llvm::dumpCodeViewMergedTypes(<br>
> CVTypeDumper CVTD(Writer, opts::CodeViewSubsectionBytes);<br>
> ArrayRef<uint8_t> BinaryData(reinterpret_cast<const uint8_t *>(Buf.data()),<br>
> Buf.size());<br>
> - if (!CVTD.dump(BinaryData)) {<br>
> + ByteStream Stream(BinaryData);<br>
> + CVTypeArray Types;<br>
> + StreamReader Reader(Stream);<br>
> + if (auto EC = Reader.readArray(Types, Reader.getLength())) {<br>
> + consumeError(std::move(EC));<br>
> + Writer.flush();<br>
> + error(object_error::parse_failed);<br>
> + }<br>
> +<br>
> + if (!CVTD.dump(Types)) {<br>
> Writer.flush();<br>
> error(object_error::parse_failed);<br>
> }<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br>
</blockquote></div>