[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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280978 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner 2016-09-08 18:36:55 +00:00
parent 684da7277a
commit 3d9234aa0a
2 changed files with 18 additions and 9 deletions

View File

@ -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));

View File

@ -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);
};
}
}