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