[PATCH] D28486: Add TypeDatabase

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 14:42:17 PST 2017


zturner created this revision.
zturner added reviewers: inglorion, rnk, amccarth.
zturner added a subscriber: llvm-commits.
Herald added a subscriber: mgorny.

Previously we had logic in `CVTypeDumper` that would try to build up a list of types that had been encountered while dumping a type stream.  All of this logic was embedded in the `CVTypeDumper` class, so it was hard to re-use anywhere else.  In practice, the idea of visiting a list of types and then using the resulting information for something will be useful for more than just dumping types.  My immediate need for this is to have a separate "compact" dump output format, where all we dump is a type's name, leaf kind, and type index, all on a single line.  This doesn't really belong in `CVTypeDumper` since it has so much additional logic to dump nested fields etc, so I wanted to make a separate compact dumper.  But in order to do this, I would need to re-implement all of this name logic.  So this patch:

1. Creates the notion of a `TypeDatabase`, which stores type indices and type record data
2. Creates a `TypeDatabaseVisitor` which builds up a `TypeDatabase` while iterating over a type stream.
3. Updates `CVTypeDumper` to use `TypeDatabaseVisitor`, by simply sticking a `TypeDatabaseVisitor` into the callback  pipeline and having `CVTypeDumper` read the same instance of `TypeDatabase` that `TypeDatabaseVisitor` writes to.

In the future, we can make `TypeDatabase` more complicated, such as storing hash values, allowing lookup by various types, and searching, and this can be the general purpose type database used for all type based operations (for example in implementing the DIA SDK in terms of native APIs)


https://reviews.llvm.org/D28486

Files:
  llvm/include/llvm/DebugInfo/CodeView/TypeDatabase.h
  llvm/include/llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h
  llvm/include/llvm/DebugInfo/CodeView/TypeDumper.h
  llvm/include/llvm/DebugInfo/MSF/StreamArray.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/DebugInfo/CodeView/CMakeLists.txt
  llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp
  llvm/lib/DebugInfo/CodeView/TypeDatabaseVisitor.cpp
  llvm/lib/DebugInfo/CodeView/TypeDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28486.83705.patch
Type: text/x-patch
Size: 44555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170109/7bb75a13/attachment.bin>


More information about the llvm-commits mailing list