diff options
| author | Zachary Turner <zturner@google.com> | 2016-09-08 18:36:55 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2016-09-08 18:36:55 +0000 |
| commit | 22b652dbf868a3f051dc91687ace4097f96df476 (patch) | |
| tree | ac4a3d44babd9a22e039f0e9e98dd3d8dd3ad5d4 | |
| parent | 35377f88f583e318495e9b754a9f16e26aaa10da (diff) | |
| download | bcm5719-llvm-22b652dbf868a3f051dc91687ace4097f96df476.tar.gz bcm5719-llvm-22b652dbf868a3f051dc91687ace4097f96df476.zip | |
[pdb] Make YamlTypeDumperCallbacks reuse *this.
Previously we were making new instances of YamlTypeDumperCallbacks
in order to recurse down and serialize / deserialize nested
records such as field lists. This meant you could not pass
context from a higher operation to a lower operation because
it would be using a new instance of the visitor callback
delegate.
YAMLIO library was updated to support context-sensitive mappings,
so now we can reuse the same instance of the visitor callback
delegate even for nested operations.
llvm-svn: 280978
| -rw-r--r-- | llvm/tools/llvm-pdbdump/CodeViewYaml.cpp | 13 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbdump/CodeViewYaml.h | 14 |
2 files changed, 18 insertions, 9 deletions
diff --git a/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp b/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp index 4817c5963c1..fd6f1941766 100644 --- a/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp +++ b/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp @@ -269,29 +269,28 @@ template <> struct ScalarTraits<APSInt> { static bool mustQuote(StringRef Scalar) { return false; } }; -void MappingTraits<CVType>::mapping(IO &IO, CVType &Record) { +void MappingContextTraits<CVType, YamlTypeDumperCallbacks>::mapping( + IO &IO, CVType &Record, YamlTypeDumperCallbacks &Dumper) { if (IO.outputting()) { codeview::TypeDeserializer Deserializer; - codeview::yaml::YamlTypeDumperCallbacks Callbacks(IO); codeview::TypeVisitorCallbackPipeline Pipeline; Pipeline.addCallbackToPipeline(Deserializer); - Pipeline.addCallbackToPipeline(Callbacks); + Pipeline.addCallbackToPipeline(Dumper); codeview::CVTypeVisitor Visitor(Pipeline); consumeError(Visitor.visitTypeRecord(Record)); } } -void MappingTraits<FieldListRecord>::mapping(IO &IO, - FieldListRecord &FieldList) { +void MappingContextTraits<FieldListRecord, YamlTypeDumperCallbacks>::mapping( + IO &IO, FieldListRecord &FieldList, YamlTypeDumperCallbacks &Dumper) { if (IO.outputting()) { - codeview::yaml::YamlTypeDumperCallbacks Callbacks(IO); codeview::TypeDeserializer Deserializer; codeview::TypeVisitorCallbackPipeline Pipeline; Pipeline.addCallbackToPipeline(Deserializer); - Pipeline.addCallbackToPipeline(Callbacks); + Pipeline.addCallbackToPipeline(Dumper); codeview::CVTypeVisitor Visitor(Pipeline); consumeError(Visitor.visitFieldListMemberStream(FieldList.Data)); diff --git a/llvm/tools/llvm-pdbdump/CodeViewYaml.h b/llvm/tools/llvm-pdbdump/CodeViewYaml.h index ccf7e406b4f..d10ed619ad7 100644 --- a/llvm/tools/llvm-pdbdump/CodeViewYaml.h +++ b/llvm/tools/llvm-pdbdump/CodeViewYaml.h @@ -57,8 +57,11 @@ template <> struct MappingTraits<codeview::MemberPointerInfo> { static void mapping(IO &IO, codeview::MemberPointerInfo &Obj); }; -template <> struct MappingTraits<codeview::CVType> { - static void mapping(IO &IO, codeview::CVType &Obj); +template <> +struct MappingContextTraits<codeview::CVType, + codeview::yaml::YamlTypeDumperCallbacks> { + static void mapping(IO &IO, codeview::CVType &Obj, + codeview::yaml::YamlTypeDumperCallbacks &Context); }; template <> struct ScalarEnumerationTraits<codeview::TypeLeafKind> { @@ -74,6 +77,13 @@ template <> struct ScalarEnumerationTraits<codeview::TypeLeafKind> { #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) #include "llvm/DebugInfo/CodeView/TypeRecords.def" + +template <> +struct MappingContextTraits<codeview::FieldListRecord, + codeview::yaml::YamlTypeDumperCallbacks> { + static void mapping(IO &IO, codeview::FieldListRecord &Record, + codeview::yaml::YamlTypeDumperCallbacks &Context); +}; } } |

