[llvm] r280978 - [pdb] Make YamlTypeDumperCallbacks reuse *this.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 8 11:36:56 PDT 2016
Author: zturner
Date: Thu Sep 8 13:36:55 2016
New Revision: 280978
URL: http://llvm.org/viewvc/llvm-project?rev=280978&view=rev
Log:
[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.
Modified:
llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp
llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h
Modified: llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp?rev=280978&r1=280977&r2=280978&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp Thu Sep 8 13:36:55 2016
@@ -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));
Modified: llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h?rev=280978&r1=280977&r2=280978&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h (original)
+++ llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h Thu Sep 8 13:36:55 2016
@@ -57,8 +57,11 @@ template <> struct MappingTraits<codevie
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 ScalarEnumerationTrai
#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);
+};
}
}
More information about the llvm-commits
mailing list