diff options
| author | Zachary Turner <zturner@google.com> | 2016-09-09 17:46:17 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2016-09-09 17:46:17 +0000 |
| commit | c6d54da891b5b7f6634d41a1c59eab4d5e226711 (patch) | |
| tree | 5d14cccb65e640255902a1280afc4ff91ee13245 /llvm/tools/llvm-pdbdump/CodeViewYaml.cpp | |
| parent | d938dfb308fe288605c6a24773ab77db8334c54a (diff) | |
| download | bcm5719-llvm-c6d54da891b5b7f6634d41a1c59eab4d5e226711.tar.gz bcm5719-llvm-c6d54da891b5b7f6634d41a1c59eab4d5e226711.zip | |
[pdb] Write PDB TPI Stream from Yaml.
This writes the full sequence of type records described in
Yaml to the TPI stream of the PDB file.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D24316
llvm-svn: 281063
Diffstat (limited to 'llvm/tools/llvm-pdbdump/CodeViewYaml.cpp')
| -rw-r--r-- | llvm/tools/llvm-pdbdump/CodeViewYaml.cpp | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp b/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp index fd6f1941766..2b3bf50fca5 100644 --- a/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp +++ b/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp @@ -9,6 +9,7 @@ #include "CodeViewYaml.h" #include "PdbYaml.h" +#include "YamlSerializationContext.h" #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" #include "llvm/DebugInfo/CodeView/EnumTables.h" @@ -269,34 +270,20 @@ template <> struct ScalarTraits<APSInt> { static bool mustQuote(StringRef Scalar) { return false; } }; -void MappingContextTraits<CVType, YamlTypeDumperCallbacks>::mapping( - IO &IO, CVType &Record, YamlTypeDumperCallbacks &Dumper) { +void MappingContextTraits<CVType, pdb::yaml::SerializationContext>::mapping( + IO &IO, CVType &Record, pdb::yaml::SerializationContext &Context) { if (IO.outputting()) { codeview::TypeDeserializer Deserializer; codeview::TypeVisitorCallbackPipeline Pipeline; Pipeline.addCallbackToPipeline(Deserializer); - Pipeline.addCallbackToPipeline(Dumper); + Pipeline.addCallbackToPipeline(Context.Dumper); codeview::CVTypeVisitor Visitor(Pipeline); consumeError(Visitor.visitTypeRecord(Record)); } } -void MappingContextTraits<FieldListRecord, YamlTypeDumperCallbacks>::mapping( - IO &IO, FieldListRecord &FieldList, YamlTypeDumperCallbacks &Dumper) { - if (IO.outputting()) { - codeview::TypeDeserializer Deserializer; - - codeview::TypeVisitorCallbackPipeline Pipeline; - Pipeline.addCallbackToPipeline(Deserializer); - Pipeline.addCallbackToPipeline(Dumper); - - codeview::CVTypeVisitor Visitor(Pipeline); - consumeError(Visitor.visitFieldListMemberStream(FieldList.Data)); - } -} - void MappingTraits<StringIdRecord>::mapping(IO &IO, StringIdRecord &String) { IO.mapRequired("Id", String.Id); IO.mapRequired("String", String.String); @@ -549,13 +536,23 @@ llvm::codeview::yaml::YamlTypeDumperCallbacks::visitTypeBegin( } void llvm::codeview::yaml::YamlTypeDumperCallbacks::visitKnownRecordImpl( - const char *Name, const CVType &Type, FieldListRecord &FieldList) { - - std::vector<llvm::pdb::yaml::PdbTpiRecord> Records; + const char *Name, const CVType &CVR, FieldListRecord &FieldList) { + std::vector<llvm::pdb::yaml::PdbTpiRecord> FieldListRecords; if (YamlIO.outputting()) { - FieldListRecordSplitter Splitter(Records); + // If we are outputting, then `FieldList.Data` contains a huge chunk of data + // representing the serialized list of members. We need to split it up into + // individual CVType records where each record represents an individual + // member. This way, we can simply map the entire thing as a Yaml sequence, + // which will recurse back to the standard handler for top-level fields + // (top-level and member fields all have the exact same Yaml syntax so use + // the same parser). + // + // If we are not outputting, then the array contains no data starting out, + // and is instead populated from the sequence represented by the yaml -- + // again, using the same logic that we use for top-level records. + FieldListRecordSplitter Splitter(FieldListRecords); CVTypeVisitor V(Splitter); consumeError(V.visitFieldListMemberStream(FieldList.Data)); } - YamlIO.mapRequired(Name, Records); + YamlIO.mapRequired("FieldList", FieldListRecords, Context); } |

