OSDN Git Service

[CodeView] Simplify the use of visiting type records & streams.
authorZachary Turner <zturner@google.com>
Wed, 17 May 2017 16:39:06 +0000 (16:39 +0000)
committerZachary Turner <zturner@google.com>
Wed, 17 May 2017 16:39:06 +0000 (16:39 +0000)
commitc254cb777d0dc5540a2aa20f067a6a28257b4131
tree1c2f92c67d421846c469a12f9c9560606372c8ba
parent66b46e1a8bba52798cca95e06fd1e9212ec061b4
[CodeView] Simplify the use of visiting type records & streams.

There is often a lot of boilerplate code required to visit a type
record or type stream.  The #1 use case is that you have a sequence
of bytes that represent one or more records, and you want to
deserialize each one, switch on it, and call a callback with the
deserialized record that the user can examine.  Currently this
requires at least 6 lines of code:

  codeview::TypeVisitorCallbackPipeline Pipeline;
  Pipeline.addCallbackToPipeline(Deserializer);
  Pipeline.addCallbackToPipeline(MyCallbacks);

  codeview::CVTypeVisitor Visitor(Pipeline);
  consumeError(Visitor.visitTypeRecord(Record));

With this patch, it becomes one line of code:

  consumeError(codeview::visitTypeRecord(Record, MyCallbacks));

This is done by having the deserialization happen internally inside
of the visitTypeRecord function.  Since this is occasionally not
desirable, the function provides a 3rd parameter that can be used
to change this behavior.

Hopefully this can significantly reduce the barrier to entry
to using the visitation infrastructure.

Differential Revision: https://reviews.llvm.org/D33245

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303271 91177308-0d34-0410-b5e6-96231b3b80d8
16 files changed:
include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
include/llvm/DebugInfo/CodeView/RandomAccessTypeVisitor.h
include/llvm/DebugInfo/PDB/Native/TpiStream.h
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
lib/DebugInfo/CodeView/CVTypeDumper.cpp
lib/DebugInfo/CodeView/CVTypeVisitor.cpp
lib/DebugInfo/CodeView/RandomAccessTypeVisitor.cpp
lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
lib/DebugInfo/CodeView/TypeStreamMerger.cpp
lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp
tools/llvm-pdbdump/Analyze.cpp
tools/llvm-pdbdump/LLVMOutputStyle.cpp
tools/llvm-pdbdump/PdbYaml.cpp
tools/llvm-pdbdump/YamlTypeDumper.cpp
unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp
unittests/DebugInfo/PDB/TypeServerHandlerTest.cpp