summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-09-02 22:19:01 +0000
committerZachary Turner <zturner@google.com>2016-09-02 22:19:01 +0000
commit83849415dea6e6fd21cf8c2dbc402c119725805c (patch)
treeba5005c44ae91348f3edd99ca1131f468ac10794 /llvm/tools
parentdad2b88c7df80b3d08f115bb5f50338459085977 (diff)
downloadbcm5719-llvm-83849415dea6e6fd21cf8c2dbc402c119725805c.tar.gz
bcm5719-llvm-83849415dea6e6fd21cf8c2dbc402c119725805c.zip
[codeview] Make FieldList records print as a yaml sequence.
Before we were kind of imitating the behavior of a Yaml sequence by outputting each record one after the other. This makes it a little cumbersome when we want to go the other direction -- from Yaml to Pdb. So this treats FieldList records as no different than any other list of records, by printing them as a Yaml sequence with the exact same format. llvm-svn: 280549
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-pdbdump/CodeViewYaml.cpp45
-rw-r--r--llvm/tools/llvm-pdbdump/CodeViewYaml.h10
2 files changed, 54 insertions, 1 deletions
diff --git a/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp b/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp
index e75f454b34a..e9dcade43ec 100644
--- a/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp
+++ b/llvm/tools/llvm-pdbdump/CodeViewYaml.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "CodeViewYaml.h"
+#include "PdbYaml.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
@@ -25,6 +26,38 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(OneMethodRecord)
LLVM_YAML_IS_SEQUENCE_VECTOR(VFTableSlotKind)
LLVM_YAML_IS_SEQUENCE_VECTOR(StringRef)
LLVM_YAML_IS_SEQUENCE_VECTOR(CVType)
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbTpiRecord)
+
+namespace {
+struct FieldListRecordSplitter : public TypeVisitorCallbacks {
+public:
+ explicit FieldListRecordSplitter(
+ std::vector<llvm::pdb::yaml::PdbTpiRecord> &Records)
+ : Records(Records) {}
+
+#define TYPE_RECORD(EnumName, EnumVal, Name)
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD(EnumName, EnumVal, Name) \
+ Error visitKnownRecord(const CVType &CVT, Name##Record &Record) override { \
+ visitKnownRecordImpl(CVT); \
+ return Error::success(); \
+ }
+#include "llvm/DebugInfo/CodeView/TypeRecords.def"
+
+private:
+ void visitKnownRecordImpl(const CVType &CVT) {
+ llvm::pdb::yaml::PdbTpiRecord R;
+ R.Record = CVT;
+ R.RecordData.assign(CVT.RawData.begin(), CVT.RawData.end());
+ R.Record.Data = R.RecordData;
+ R.Record.RawData = R.RecordData;
+ Records.push_back(std::move(R));
+ }
+
+ std::vector<llvm::pdb::yaml::PdbTpiRecord> &Records;
+};
+}
namespace llvm {
namespace yaml {
@@ -518,3 +551,15 @@ llvm::codeview::yaml::YamlTypeDumperCallbacks::visitTypeBegin(
YamlIO.mapRequired("Kind", K);
return K;
}
+
+void llvm::codeview::yaml::YamlTypeDumperCallbacks::visitKnownRecordImpl(
+ const char *Name, const CVType &Type, FieldListRecord &FieldList) {
+
+ std::vector<llvm::pdb::yaml::PdbTpiRecord> Records;
+ if (YamlIO.outputting()) {
+ FieldListRecordSplitter Splitter(Records);
+ CVTypeVisitor V(Splitter);
+ consumeError(V.visitFieldListMemberStream(FieldList.Data));
+ }
+ YamlIO.mapRequired(Name, Records);
+}
diff --git a/llvm/tools/llvm-pdbdump/CodeViewYaml.h b/llvm/tools/llvm-pdbdump/CodeViewYaml.h
index 8932d008ca3..ccf7e406b4f 100644
--- a/llvm/tools/llvm-pdbdump/CodeViewYaml.h
+++ b/llvm/tools/llvm-pdbdump/CodeViewYaml.h
@@ -27,7 +27,7 @@ public:
#define TYPE_RECORD(EnumName, EnumVal, Name) \
Error visitKnownRecord(const CVRecord<TypeLeafKind> &CVR, \
Name##Record &Record) override { \
- YamlIO.mapRequired(#Name, Record); \
+ visitKnownRecordImpl(#Name, CVR, Record); \
return Error::success(); \
}
#define MEMBER_RECORD(EnumName, EnumVal, Name) \
@@ -37,6 +37,14 @@ public:
#include "llvm/DebugInfo/CodeView/TypeRecords.def"
private:
+ template <typename T>
+ void visitKnownRecordImpl(const char *Name, const CVType &Type, T &Record) {
+ YamlIO.mapRequired(Name, Record);
+ }
+
+ void visitKnownRecordImpl(const char *Name, const CVType &Type,
+ FieldListRecord &FieldList);
+
llvm::yaml::IO &YamlIO;
};
}
OpenPOWER on IntegriCloud