[PATCH] D21128: [pdb] Fix errors with invalid stream numbers

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 06:07:24 PDT 2016


zturner created this revision.
zturner added reviewers: majnemer, rnk, ruiu.
zturner added a subscriber: llvm-commits.

This should fix most, if not all of the llvm-pdbdump-fuzzer errors.  The problem is that we were not always checking that stream numbers were valid.  This fixes that by making the constructor to `MappedBlockStream` private and only exposing it through a static creator which returns an `Expected<unique_ptr<MappedBlockStream>>`.  

One problem that came up is that it's getting pretty ugly to write 4-5 lines of code to check an `Expected<T>` and return the error every time.  I had the idea to wrap this up in some macros, but unfortunately it didn't go very well.  You can see the results here.  I could not find a way to do it without 6 different macros.  If anyone can think of a way to make this less onerous, I'm all ears.  Requirements:

  # It should work if you have a failed `Expected<T>` and on error you return a failed `Expected<U>`, where T != U.
  # It should work if you have a failed `Expected<T>` and you are returning an `llvm::Error`.
  # It should work if T is a reference type, such as `Expected<DbiStream&>`.
  # It should work if T is not copyable, such as `Expected<std::unique_ptr<MappedBlockStream>>`.
  # It should work if you want the "success" value to go into an existing variable (such as a class member variable)
  # It should work if you don't have a success variable declared and you want the macro to auto-declare it.



http://reviews.llvm.org/D21128

Files:
  include/llvm/DebugInfo/PDB/Raw/DbiStream.h
  include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h
  include/llvm/DebugInfo/PDB/Raw/InfoStream.h
  include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h
  include/llvm/DebugInfo/PDB/Raw/ModStream.h
  include/llvm/DebugInfo/PDB/Raw/PublicsStream.h
  include/llvm/DebugInfo/PDB/Raw/RawError.h
  include/llvm/DebugInfo/PDB/Raw/SymbolStream.h
  include/llvm/DebugInfo/PDB/Raw/TpiStream.h
  include/llvm/Support/Error.h
  lib/DebugInfo/PDB/Raw/DbiStream.cpp
  lib/DebugInfo/PDB/Raw/InfoStream.cpp
  lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
  lib/DebugInfo/PDB/Raw/ModStream.cpp
  lib/DebugInfo/PDB/Raw/PDBFile.cpp
  lib/DebugInfo/PDB/Raw/PublicsStream.cpp
  lib/DebugInfo/PDB/Raw/SymbolStream.cpp
  lib/DebugInfo/PDB/Raw/TpiStream.cpp
  tools/llvm-pdbdump/LLVMOutputStyle.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21128.60020.patch
Type: text/x-patch
Size: 39015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160608/1440dbfa/attachment.bin>


More information about the llvm-commits mailing list