aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-01 20:58:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-01 20:58:36 +0000
commitf382538d471e38a9b98f016c4caebd24c8d60b62 (patch)
treed30f3d58b1044b5355d50c17a6a96c6a0b35703a /tools
parentee2f195dd3e40f49698ca4dc2666ec09c770e80d (diff)
downloadsrc-f382538d471e38a9b98f016c4caebd24c8d60b62.tar.gz
src-f382538d471e38a9b98f016c4caebd24c8d60b62.zip
Vendor import of llvm trunk r304460:vendor/llvm/llvm-trunk-r304460
Notes
Notes: svn path=/vendor/llvm/dist/; revision=319461 svn path=/vendor/llvm/llvm-trunk-r304460/; revision=319462; tag=vendor/llvm/llvm-trunk-r304460
Diffstat (limited to 'tools')
-rw-r--r--tools/bugpoint/OptimizerDriver.cpp11
-rw-r--r--tools/llvm-config/BuildVariables.inc.in1
-rw-r--r--tools/llvm-config/llvm-config.cpp4
-rw-r--r--tools/llvm-cvtres/llvm-cvtres.cpp32
-rw-r--r--tools/llvm-dwarfdump/llvm-dwarfdump.cpp6
-rw-r--r--tools/llvm-objdump/MachODump.cpp5
-rw-r--r--tools/llvm-objdump/llvm-objdump.cpp5
-rw-r--r--tools/llvm-pdbdump/Analyze.cpp2
-rw-r--r--tools/llvm-pdbdump/CMakeLists.txt3
-rw-r--r--tools/llvm-pdbdump/CompactTypeDumpVisitor.cpp2
-rw-r--r--tools/llvm-pdbdump/PdbYaml.cpp200
-rw-r--r--tools/llvm-pdbdump/PdbYaml.h207
-rw-r--r--tools/llvm-pdbdump/YAMLOutputStyle.cpp43
-rw-r--r--tools/llvm-pdbdump/YAMLOutputStyle.h2
-rw-r--r--tools/llvm-pdbdump/YamlSerializationContext.h39
-rw-r--r--tools/llvm-pdbdump/YamlSymbolDumper.cpp413
-rw-r--r--tools/llvm-pdbdump/YamlSymbolDumper.h66
-rw-r--r--tools/llvm-pdbdump/YamlTypeDumper.cpp589
-rw-r--r--tools/llvm-pdbdump/YamlTypeDumper.h116
-rw-r--r--tools/llvm-pdbdump/llvm-pdbdump.cpp17
-rw-r--r--tools/llvm-readobj/ELFDumper.cpp1
-rw-r--r--tools/obj2yaml/macho2yaml.cpp2
-rw-r--r--tools/opt/NewPMDriver.cpp15
-rw-r--r--tools/opt/NewPMDriver.h10
-rw-r--r--tools/opt/opt.cpp6
25 files changed, 136 insertions, 1661 deletions
diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp
index 246580c8bdbe..ae3a31adaea3 100644
--- a/tools/bugpoint/OptimizerDriver.cpp
+++ b/tools/bugpoint/OptimizerDriver.cpp
@@ -47,14 +47,13 @@ static cl::opt<bool> PreserveBitcodeUseListOrder(
cl::desc("Preserve use-list order when writing LLVM bitcode."),
cl::init(true), cl::Hidden);
-namespace {
// ChildOutput - This option captures the name of the child output file that
// is set up by the parent bugpoint process
-cl::opt<std::string> ChildOutput("child-output", cl::ReallyHidden);
-cl::opt<std::string> OptCmd("opt-command", cl::init(""),
- cl::desc("Path to opt. (default: search path "
- "for 'opt'.)"));
-}
+static cl::opt<std::string> ChildOutput("child-output", cl::ReallyHidden);
+static cl::opt<std::string>
+ OptCmd("opt-command", cl::init(""),
+ cl::desc("Path to opt. (default: search path "
+ "for 'opt'.)"));
/// writeProgramToFile - This writes the current "Program" to the named bitcode
/// file. If an error occurs, true is returned.
diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
index 0740c3f9d9f5..f201e1f7bff0 100644
--- a/tools/llvm-config/BuildVariables.inc.in
+++ b/tools/llvm-config/BuildVariables.inc.in
@@ -34,3 +34,4 @@
#define LLVM_DYLIB_COMPONENTS "@LLVM_DYLIB_COMPONENTS@"
#define LLVM_DYLIB_VERSION "@LLVM_DYLIB_VERSION@"
#define LLVM_HAS_GLOBAL_ISEL @LLVM_HAS_GLOBAL_ISEL@
+#define LLVM_TOOLS_INSTALL_DIR "@LLVM_TOOLS_INSTALL_DIR@"
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 25344e4cd011..888da7143c9f 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -333,7 +333,9 @@ int main(int argc, char **argv) {
} else {
ActivePrefix = CurrentExecPrefix;
ActiveIncludeDir = ActivePrefix + "/include";
- ActiveBinDir = ActivePrefix + "/bin";
+ SmallString<PATH_MAX> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
+ sys::fs::make_absolute(ActivePrefix, path);
+ ActiveBinDir = path.str();
ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
ActiveIncludeOption = "-I" + ActiveIncludeDir;
diff --git a/tools/llvm-cvtres/llvm-cvtres.cpp b/tools/llvm-cvtres/llvm-cvtres.cpp
index 96f7437ab5f6..95a6623b44eb 100644
--- a/tools/llvm-cvtres/llvm-cvtres.cpp
+++ b/tools/llvm-cvtres/llvm-cvtres.cpp
@@ -131,7 +131,7 @@ int main(int argc_, const char *argv_[]) {
std::vector<std::string> InputFiles = InputArgs.getAllArgValues(OPT_INPUT);
if (InputFiles.size() == 0) {
- reportError("No input file specified");
+ reportError("No input file specified.\n");
}
SmallString<128> OutputFile;
@@ -143,6 +143,20 @@ int main(int argc_, const char *argv_[]) {
llvm::sys::path::replace_extension(OutputFile, ".obj");
}
+ outs() << "Machine: ";
+ switch (Machine) {
+ case machine::ARM:
+ outs() << "ARM\n";
+ break;
+ case machine::X86:
+ outs() << "X86\n";
+ break;
+ default:
+ outs() << "X64\n";
+ }
+
+ WindowsResourceParser Parser;
+
for (const auto &File : InputFiles) {
Expected<object::OwningBinary<object::Binary>> BinaryOrErr =
object::createBinary(File);
@@ -166,17 +180,11 @@ int main(int argc_, const char *argv_[]) {
EntryNumber++;
}
outs() << "Number of resources: " << EntryNumber << "\n";
+
+ error(Parser.parse(RF));
}
- outs() << "Machine: ";
- switch (Machine) {
- case machine::ARM:
- outs() << "ARM\n";
- break;
- case machine::X86:
- outs() << "X86\n";
- break;
- default:
- outs() << "X64\n";
- }
+
+ Parser.printTree();
+
return 0;
}
diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 8ecf18480994..2b5babe79824 100644
--- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -95,8 +95,12 @@ static void DumpObjectFile(ObjectFile &Obj, Twine Filename) {
outs() << Filename.str() << ":\tfile format " << Obj.getFileFormatName()
<< "\n\n";
+
// Dump the complete DWARF structure.
- DICtx->dump(outs(), DumpType, false, SummarizeTypes);
+ DIDumpOptions DumpOpts;
+ DumpOpts.DumpType = DumpType;
+ DumpOpts.SummarizeTypes = SummarizeTypes;
+ DICtx->dump(outs(), DumpOpts);
}
static void DumpInput(StringRef Filename) {
diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp
index 9e02951a4a93..a260d6ff42c5 100644
--- a/tools/llvm-objdump/MachODump.cpp
+++ b/tools/llvm-objdump/MachODump.cpp
@@ -1271,7 +1271,10 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
if (DwarfDumpType != DIDT_Null) {
std::unique_ptr<DIContext> DICtx(new DWARFContextInMemory(*MachOOF));
// Dump the complete DWARF structure.
- DICtx->dump(outs(), DwarfDumpType, true /* DumpEH */);
+ DIDumpOptions DumpOpts;
+ DumpOpts.DumpType = DwarfDumpType;
+ DumpOpts.DumpEH = true;
+ DICtx->dump(outs(), DumpOpts);
}
}
diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp
index 18fa0e074084..6a9151570908 100644
--- a/tools/llvm-objdump/llvm-objdump.cpp
+++ b/tools/llvm-objdump/llvm-objdump.cpp
@@ -2064,7 +2064,10 @@ static void DumpObject(ObjectFile *o, const Archive *a = nullptr) {
if (DwarfDumpType != DIDT_Null) {
std::unique_ptr<DIContext> DICtx(new DWARFContextInMemory(*o));
// Dump the complete DWARF structure.
- DICtx->dump(outs(), DwarfDumpType, true /* DumpEH */);
+ DIDumpOptions DumpOpts;
+ DumpOpts.DumpType = DwarfDumpType;
+ DumpOpts.DumpEH = true;
+ DICtx->dump(outs(), DumpOpts);
}
}
diff --git a/tools/llvm-pdbdump/Analyze.cpp b/tools/llvm-pdbdump/Analyze.cpp
index 3a026e5d2451..b503cdcbf1ea 100644
--- a/tools/llvm-pdbdump/Analyze.cpp
+++ b/tools/llvm-pdbdump/Analyze.cpp
@@ -35,7 +35,7 @@ static StringRef getLeafTypeName(TypeLeafKind LT) {
#define TYPE_RECORD(ename, value, name) \
case ename: \
return #name;
-#include "llvm/DebugInfo/CodeView/TypeRecords.def"
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
default:
break;
}
diff --git a/tools/llvm-pdbdump/CMakeLists.txt b/tools/llvm-pdbdump/CMakeLists.txt
index 325e38c15ca7..a1f54a3bff6a 100644
--- a/tools/llvm-pdbdump/CMakeLists.txt
+++ b/tools/llvm-pdbdump/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
DebugInfoMSF
DebugInfoPDB
Object
+ ObjectYAML
Support
)
@@ -12,8 +13,6 @@ add_llvm_tool(llvm-pdbdump
CompactTypeDumpVisitor.cpp
Diff.cpp
llvm-pdbdump.cpp
- YamlSymbolDumper.cpp
- YamlTypeDumper.cpp
LinePrinter.cpp
LLVMOutputStyle.cpp
PdbYaml.cpp
diff --git a/tools/llvm-pdbdump/CompactTypeDumpVisitor.cpp b/tools/llvm-pdbdump/CompactTypeDumpVisitor.cpp
index 3b609ae50c1c..6dd54e0dbec1 100644
--- a/tools/llvm-pdbdump/CompactTypeDumpVisitor.cpp
+++ b/tools/llvm-pdbdump/CompactTypeDumpVisitor.cpp
@@ -18,7 +18,7 @@ using namespace llvm::pdb;
static const EnumEntry<TypeLeafKind> LeafTypeNames[] = {
#define CV_TYPE(enum, val) {#enum, enum},
-#include "llvm/DebugInfo/CodeView/TypeRecords.def"
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
};
static StringRef getLeafName(TypeLeafKind K) {
diff --git a/tools/llvm-pdbdump/PdbYaml.cpp b/tools/llvm-pdbdump/PdbYaml.cpp
index dd32eca14c1d..e288063e2afa 100644
--- a/tools/llvm-pdbdump/PdbYaml.cpp
+++ b/tools/llvm-pdbdump/PdbYaml.cpp
@@ -9,22 +9,19 @@
#include "PdbYaml.h"
-#include "YamlSerializationContext.h"
-#include "YamlSymbolDumper.h"
-#include "YamlTypeDumper.h"
-
#include "llvm/ADT/StringExtras.h"
#include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
-#include "llvm/DebugInfo/CodeView/SymbolSerializer.h"
#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
#include "llvm/DebugInfo/CodeView/TypeSerializer.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
+#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include "llvm/DebugInfo/PDB/Native/TpiHashing.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
+#include "llvm/ObjectYAML/CodeViewYAMLTypes.h"
using namespace llvm;
using namespace llvm::pdb;
@@ -35,15 +32,6 @@ LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint32_t)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::StringRef)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::NamedStreamMapping)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbDbiModuleInfo)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbSourceFileChecksumEntry)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbSourceLineEntry)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbSourceColumnEntry)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbSourceLineBlock)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbSourceLineInfo)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbInlineeSite)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbInlineeInfo)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbSymbolRecord)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbTpiRecord)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::StreamBlockList)
LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::pdb::PdbRaw_FeatureSig)
@@ -152,57 +140,18 @@ template <> struct ScalarEnumerationTraits<llvm::pdb::PdbRaw_FeatureSig> {
io.enumCase(Features, "VC140", PdbRaw_FeatureSig::VC140);
}
};
-
-template <> struct ScalarEnumerationTraits<llvm::codeview::FileChecksumKind> {
- static void enumeration(IO &io, llvm::codeview::FileChecksumKind &Kind) {
- io.enumCase(Kind, "None", llvm::codeview::FileChecksumKind::None);
- io.enumCase(Kind, "MD5", llvm::codeview::FileChecksumKind::MD5);
- io.enumCase(Kind, "SHA1", llvm::codeview::FileChecksumKind::SHA1);
- io.enumCase(Kind, "SHA256", llvm::codeview::FileChecksumKind::SHA256);
- }
-};
-
-template <> struct ScalarBitSetTraits<llvm::codeview::LineFlags> {
- static void bitset(IO &io, llvm::codeview::LineFlags &Flags) {
- io.bitSetCase(Flags, "HasColumnInfo", llvm::codeview::LF_HaveColumns);
- io.enumFallback<Hex16>(Flags);
- }
-};
-}
-}
-
-void ScalarTraits<HexFormattedString>::output(const HexFormattedString &Value,
- void *ctx, raw_ostream &Out) {
- StringRef Bytes(reinterpret_cast<const char *>(Value.Bytes.data()),
- Value.Bytes.size());
- Out << toHex(Bytes);
}
-
-StringRef ScalarTraits<HexFormattedString>::input(StringRef Scalar, void *ctxt,
- HexFormattedString &Value) {
- std::string H = fromHex(Scalar);
- Value.Bytes.assign(H.begin(), H.end());
- return StringRef();
}
void MappingTraits<PdbObject>::mapping(IO &IO, PdbObject &Obj) {
- // Create a single serialization context that will be passed through the
- // entire process of serializing / deserializing a Tpi Stream. This is
- // especially important when we are going from Pdb -> Yaml because we need
- // to maintain state in a TypeTableBuilder across mappings, and at the end of
- // the entire process, we need to have one TypeTableBuilder that has every
- // record.
- pdb::yaml::SerializationContext Context(IO, Obj.Allocator);
-
-
IO.mapOptional("MSF", Obj.Headers);
IO.mapOptional("StreamSizes", Obj.StreamSizes);
IO.mapOptional("StreamMap", Obj.StreamMap);
IO.mapOptional("StringTable", Obj.StringTable);
IO.mapOptional("PdbStream", Obj.PdbStream);
- IO.mapOptionalWithContext("DbiStream", Obj.DbiStream, Context);
- IO.mapOptionalWithContext("TpiStream", Obj.TpiStream, Context);
- IO.mapOptionalWithContext("IpiStream", Obj.IpiStream, Context);
+ IO.mapOptional("DbiStream", Obj.DbiStream);
+ IO.mapOptional("TpiStream", Obj.TpiStream);
+ IO.mapOptional("IpiStream", Obj.IpiStream);
}
void MappingTraits<MSFHeaders>::mapping(IO &IO, MSFHeaders &Obj) {
@@ -239,7 +188,7 @@ void MappingTraits<PdbInfoStream>::mapping(IO &IO, PdbInfoStream &Obj) {
IO.mapOptional("Version", Obj.Version, PdbImplVC70);
}
-void MappingContextTraits<PdbDbiStream, pdb::yaml::SerializationContext>::mapping(IO &IO, PdbDbiStream &Obj, pdb::yaml::SerializationContext &Context) {
+void MappingTraits<PdbDbiStream>::mapping(IO &IO, PdbDbiStream &Obj) {
IO.mapOptional("VerHeader", Obj.VerHeader, PdbDbiV70);
IO.mapOptional("Age", Obj.Age, 1U);
IO.mapOptional("BuildNumber", Obj.BuildNumber, uint16_t(0U));
@@ -247,13 +196,13 @@ void MappingContextTraits<PdbDbiStream, pdb::yaml::SerializationContext>::mappin
IO.mapOptional("PdbDllRbld", Obj.PdbDllRbld, uint16_t(0U));
IO.mapOptional("Flags", Obj.Flags, uint16_t(1U));
IO.mapOptional("MachineType", Obj.MachineType, PDB_Machine::x86);
- IO.mapOptionalWithContext("Modules", Obj.ModInfos, Context);
+ IO.mapOptional("Modules", Obj.ModInfos);
}
-void MappingContextTraits<PdbTpiStream, pdb::yaml::SerializationContext>::mapping(
- IO &IO, pdb::yaml::PdbTpiStream &Obj, pdb::yaml::SerializationContext &Context) {
+void MappingTraits<PdbTpiStream>::mapping(IO &IO,
+ pdb::yaml::PdbTpiStream &Obj) {
IO.mapOptional("Version", Obj.Version, PdbTpiV80);
- IO.mapRequired("Records", Obj.Records, Context);
+ IO.mapRequired("Records", Obj.Records);
}
void MappingTraits<NamedStreamMapping>::mapping(IO &IO,
@@ -262,134 +211,15 @@ void MappingTraits<NamedStreamMapping>::mapping(IO &IO,
IO.mapRequired("StreamNum", Obj.StreamNumber);
}
-void MappingContextTraits<PdbSymbolRecord, pdb::yaml::SerializationContext>::mapping(IO &IO, PdbSymbolRecord &Obj, pdb::yaml::SerializationContext &Context) {
- codeview::SymbolVisitorCallbackPipeline Pipeline;
- codeview::SymbolSerializer Serializer(Context.Allocator);
- codeview::SymbolDeserializer Deserializer(nullptr);
- codeview::yaml::YamlSymbolDumper Dumper(IO);
-
- if (IO.outputting()) {
- // For PDB to Yaml, deserialize into a high level record type, then dump it.
- Pipeline.addCallbackToPipeline(Deserializer);
- Pipeline.addCallbackToPipeline(Dumper);
- } else {
- // For the other way around, dump it into a concrete structure, and then
- // serialize it into the CVRecord.
- Pipeline.addCallbackToPipeline(Dumper);
- Pipeline.addCallbackToPipeline(Serializer);
- }
-
- codeview::CVSymbolVisitor Visitor(Pipeline);
- consumeError(Visitor.visitSymbolRecord(Obj.Record));
-}
-
-void MappingContextTraits<PdbModiStream, pdb::yaml::SerializationContext>::mapping(IO &IO, PdbModiStream &Obj, pdb::yaml::SerializationContext &Context) {
+void MappingTraits<PdbModiStream>::mapping(IO &IO, PdbModiStream &Obj) {
IO.mapOptional("Signature", Obj.Signature, 4U);
- IO.mapRequired("Records", Obj.Symbols, Context);
+ IO.mapRequired("Records", Obj.Symbols);
}
-void MappingContextTraits<PdbDbiModuleInfo, pdb::yaml::SerializationContext>::mapping(IO &IO, PdbDbiModuleInfo &Obj, pdb::yaml::SerializationContext &Context) {
+void MappingTraits<PdbDbiModuleInfo>::mapping(IO &IO, PdbDbiModuleInfo &Obj) {
IO.mapRequired("Module", Obj.Mod);
IO.mapOptional("ObjFile", Obj.Obj, Obj.Mod);
IO.mapOptional("SourceFiles", Obj.SourceFiles);
- IO.mapOptionalWithContext("LineInfo", Obj.FileLineInfo, Context);
- IO.mapOptionalWithContext("Modi", Obj.Modi, Context);
-}
-
-void MappingContextTraits<pdb::yaml::PdbSourceLineEntry,
- pdb::yaml::SerializationContext>::
- mapping(IO &IO, PdbSourceLineEntry &Obj,
- pdb::yaml::SerializationContext &Context) {
- IO.mapRequired("Offset", Obj.Offset);
- IO.mapRequired("LineStart", Obj.LineStart);
- IO.mapRequired("IsStatement", Obj.IsStatement);
- IO.mapRequired("EndDelta", Obj.EndDelta);
-}
-
-void MappingContextTraits<pdb::yaml::PdbSourceColumnEntry,
- pdb::yaml::SerializationContext>::
- mapping(IO &IO, PdbSourceColumnEntry &Obj,
- pdb::yaml::SerializationContext &Context) {
- IO.mapRequired("StartColumn", Obj.StartColumn);
- IO.mapRequired("EndColumn", Obj.EndColumn);
-}
-
-void MappingContextTraits<pdb::yaml::PdbSourceLineBlock,
- pdb::yaml::SerializationContext>::
- mapping(IO &IO, PdbSourceLineBlock &Obj,
- pdb::yaml::SerializationContext &Context) {
- IO.mapRequired("FileName", Obj.FileName);
- IO.mapRequired("Lines", Obj.Lines, Context);
- IO.mapRequired("Columns", Obj.Columns, Context);
-}
-
-void MappingContextTraits<pdb::yaml::PdbSourceFileChecksumEntry,
- pdb::yaml::SerializationContext>::
- mapping(IO &IO, PdbSourceFileChecksumEntry &Obj,
- pdb::yaml::SerializationContext &Context) {
- IO.mapRequired("FileName", Obj.FileName);
- IO.mapRequired("Kind", Obj.Kind);
- IO.mapRequired("Checksum", Obj.ChecksumBytes);
-}
-
-void MappingContextTraits<pdb::yaml::PdbSourceLineInfo,
- pdb::yaml::SerializationContext>::
- mapping(IO &IO, PdbSourceLineInfo &Obj,
- pdb::yaml::SerializationContext &Context) {
- IO.mapRequired("CodeSize", Obj.CodeSize);
-
- IO.mapRequired("Flags", Obj.Flags);
- IO.mapRequired("RelocOffset", Obj.RelocOffset);
- IO.mapRequired("RelocSegment", Obj.RelocSegment);
- IO.mapRequired("Blocks", Obj.Blocks, Context);
-}
-
-void MappingContextTraits<pdb::yaml::PdbSourceFileInfo,
- pdb::yaml::SerializationContext>::
- mapping(IO &IO, PdbSourceFileInfo &Obj,
- pdb::yaml::SerializationContext &Context) {
- IO.mapOptionalWithContext("Checksums", Obj.FileChecksums, Context);
- IO.mapOptionalWithContext("Lines", Obj.LineFragments, Context);
- IO.mapOptionalWithContext("InlineeLines", Obj.Inlinees, Context);
-}
-
-void MappingContextTraits<PdbInlineeSite, SerializationContext>::mapping(
- IO &IO, PdbInlineeSite &Obj, SerializationContext &Context) {
- IO.mapRequired("FileName", Obj.FileName);
- IO.mapRequired("LineNum", Obj.SourceLineNum);
- IO.mapRequired("Inlinee", Obj.Inlinee);
- IO.mapOptional("ExtraFiles", Obj.ExtraFiles);
-}
-
-void MappingContextTraits<PdbInlineeInfo, SerializationContext>::mapping(
- IO &IO, PdbInlineeInfo &Obj, SerializationContext &Context) {
- IO.mapRequired("HasExtraFiles", Obj.HasExtraFiles);
- IO.mapRequired("Sites", Obj.Sites, Context);
-}
-
-void MappingContextTraits<PdbTpiRecord, pdb::yaml::SerializationContext>::
- mapping(IO &IO, pdb::yaml::PdbTpiRecord &Obj,
- pdb::yaml::SerializationContext &Context) {
- if (IO.outputting()) {
- // For PDB to Yaml, deserialize into a high level record type, then dump it.
- consumeError(codeview::visitTypeRecord(Obj.Record, Context.Dumper));
- } else {
- codeview::TypeVisitorCallbackPipeline Pipeline;
- codeview::TypeSerializer Serializer(Context.Allocator);
- pdb::TpiHashUpdater Hasher;
- // For Yaml to PDB, extract from the high level record type, then write it
- // to bytes.
-
- // This might be interpreted as a hack, but serializing FieldList
- // sub-records requires having access to the same serializer being used by
- // the FieldList itself.
- Context.ActiveSerializer = &Serializer;
- Pipeline.addCallbackToPipeline(Context.Dumper);
- Pipeline.addCallbackToPipeline(Serializer);
- Pipeline.addCallbackToPipeline(Hasher);
- consumeError(codeview::visitTypeRecord(Obj.Record, Pipeline,
- codeview::VDS_BytesExternal));
- }
-
- Context.ActiveSerializer = nullptr;
+ IO.mapOptional("LineInfo", Obj.FileLineInfo);
+ IO.mapOptional("Modi", Obj.Modi);
}
diff --git a/tools/llvm-pdbdump/PdbYaml.h b/tools/llvm-pdbdump/PdbYaml.h
index 423845caeb31..deb500ec2074 100644
--- a/tools/llvm-pdbdump/PdbYaml.h
+++ b/tools/llvm-pdbdump/PdbYaml.h
@@ -19,6 +19,9 @@
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
+#include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h"
+#include "llvm/ObjectYAML/CodeViewYAMLSymbols.h"
+#include "llvm/ObjectYAML/CodeViewYAMLTypes.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/YAMLTraits.h"
@@ -56,75 +59,16 @@ struct PdbInfoStream {
std::vector<NamedStreamMapping> NamedStreams;
};
-struct PdbSymbolRecord {
- codeview::CVSymbol Record;
-};
-
struct PdbModiStream {
uint32_t Signature;
- std::vector<PdbSymbolRecord> Symbols;
-};
-
-struct PdbSourceLineEntry {
- uint32_t Offset;
- uint32_t LineStart;
- uint32_t EndDelta;
- bool IsStatement;
-};
-
-struct PdbSourceColumnEntry {
- uint16_t StartColumn;
- uint16_t EndColumn;
-};
-
-struct PdbSourceLineBlock {
- StringRef FileName;
- std::vector<PdbSourceLineEntry> Lines;
- std::vector<PdbSourceColumnEntry> Columns;
-};
-
-struct HexFormattedString {
- std::vector<uint8_t> Bytes;
-};
-
-struct PdbSourceFileChecksumEntry {
- StringRef FileName;
- codeview::FileChecksumKind Kind;
- HexFormattedString ChecksumBytes;
-};
-
-struct PdbSourceLineInfo {
- uint32_t RelocOffset;
- uint32_t RelocSegment;
- codeview::LineFlags Flags;
- uint32_t CodeSize;
-
- std::vector<PdbSourceLineBlock> Blocks;
-};
-
-struct PdbInlineeSite {
- codeview::TypeIndex Inlinee;
- StringRef FileName;
- uint32_t SourceLineNum;
- std::vector<StringRef> ExtraFiles;
-};
-
-struct PdbInlineeInfo {
- bool HasExtraFiles;
- std::vector<PdbInlineeSite> Sites;
-};
-
-struct PdbSourceFileInfo {
- std::vector<PdbSourceFileChecksumEntry> FileChecksums;
- std::vector<PdbSourceLineInfo> LineFragments;
- std::vector<PdbInlineeInfo> Inlinees;
+ std::vector<CodeViewYAML::SymbolRecord> Symbols;
};
struct PdbDbiModuleInfo {
StringRef Obj;
StringRef Mod;
std::vector<StringRef> SourceFiles;
- Optional<PdbSourceFileInfo> FileLineInfo;
+ Optional<CodeViewYAML::SourceFileInfo> FileLineInfo;
Optional<PdbModiStream> Modi;
};
@@ -140,17 +84,9 @@ struct PdbDbiStream {
std::vector<PdbDbiModuleInfo> ModInfos;
};
-struct PdbTpiRecord {
- codeview::CVType Record;
-};
-
-struct PdbTpiFieldListRecord {
- codeview::CVMemberRecord Record;
-};
-
struct PdbTpiStream {
PdbRaw_TpiVer Version = PdbTpiV80;
- std::vector<PdbTpiRecord> Records;
+ std::vector<CodeViewYAML::LeafRecord> Records;
};
struct PdbObject {
@@ -172,126 +108,15 @@ struct PdbObject {
}
}
-namespace llvm {
-namespace yaml {
-
-template <> struct MappingTraits<pdb::yaml::PdbObject> {
- static void mapping(IO &IO, pdb::yaml::PdbObject &Obj);
-};
-
-template <> struct MappingTraits<pdb::yaml::MSFHeaders> {
- static void mapping(IO &IO, pdb::yaml::MSFHeaders &Obj);
-};
-
-template <> struct MappingTraits<msf::SuperBlock> {
- static void mapping(IO &IO, msf::SuperBlock &SB);
-};
-
-template <> struct MappingTraits<pdb::yaml::StreamBlockList> {
- static void mapping(IO &IO, pdb::yaml::StreamBlockList &SB);
-};
-
-template <> struct MappingTraits<pdb::yaml::PdbInfoStream> {
- static void mapping(IO &IO, pdb::yaml::PdbInfoStream &Obj);
-};
-
-template <> struct MappingContextTraits<pdb::yaml::PdbDbiStream, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbDbiStream &Obj, pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbTpiStream, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbTpiStream &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct MappingTraits<pdb::yaml::NamedStreamMapping> {
- static void mapping(IO &IO, pdb::yaml::NamedStreamMapping &Obj);
-};
-
-template <> struct MappingContextTraits<pdb::yaml::PdbSymbolRecord, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSymbolRecord &Obj, pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct MappingContextTraits<pdb::yaml::PdbModiStream, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbModiStream &Obj, pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct MappingContextTraits<pdb::yaml::PdbDbiModuleInfo, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbDbiModuleInfo &Obj, pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceLineEntry,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceLineEntry &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceColumnEntry,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceColumnEntry &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceLineBlock,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceLineBlock &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceFileChecksumEntry,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceFileChecksumEntry &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct ScalarTraits<pdb::yaml::HexFormattedString> {
- static void output(const pdb::yaml::HexFormattedString &Value, void *ctx,
- llvm::raw_ostream &Out);
- static StringRef input(StringRef Scalar, void *ctxt,
- pdb::yaml::HexFormattedString &Value);
- static bool mustQuote(StringRef) { return false; }
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceLineInfo,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceLineInfo &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceFileInfo,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceFileInfo &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbInlineeInfo,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbInlineeInfo &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbInlineeSite,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbInlineeSite &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbTpiRecord,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbTpiRecord &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-}
-}
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbObject)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::MSFHeaders)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(msf::SuperBlock)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::StreamBlockList)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbInfoStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbTpiStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::NamedStreamMapping)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbModiStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiModuleInfo)
#endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
diff --git a/tools/llvm-pdbdump/YAMLOutputStyle.cpp b/tools/llvm-pdbdump/YAMLOutputStyle.cpp
index 7aa68dee7d47..18839a7679d3 100644
--- a/tools/llvm-pdbdump/YAMLOutputStyle.cpp
+++ b/tools/llvm-pdbdump/YAMLOutputStyle.cpp
@@ -104,12 +104,12 @@ Error YAMLOutputStyle::dump() {
namespace {
class C13YamlVisitor : public C13DebugFragmentVisitor {
public:
- C13YamlVisitor(llvm::pdb::yaml::PdbSourceFileInfo &Info, PDBFile &F)
+ C13YamlVisitor(CodeViewYAML::SourceFileInfo &Info, PDBFile &F)
: C13DebugFragmentVisitor(F), Info(Info) {}
Error handleFileChecksums() override {
for (const auto &C : *Checksums) {
- llvm::pdb::yaml::PdbSourceFileChecksumEntry Entry;
+ CodeViewYAML::SourceFileChecksumEntry Entry;
if (auto Result = getNameFromStringTable(C.FileNameOffset))
Entry.FileName = *Result;
else
@@ -143,7 +143,7 @@ public:
return Result.takeError();
for (const auto &N : L.LineNumbers) {
- llvm::pdb::yaml::PdbSourceLineEntry Line;
+ CodeViewYAML::SourceLineEntry Line;
Line.Offset = N.Offset;
codeview::LineInfo LI(N.Flags);
Line.LineStart = LI.getStartLine();
@@ -154,7 +154,7 @@ public:
if (LF.hasColumnInfo()) {
for (const auto &C : L.Columns) {
- llvm::pdb::yaml::PdbSourceColumnEntry Column;
+ CodeViewYAML::SourceColumnEntry Column;
Column.StartColumn = C.StartColumn;
Column.EndColumn = C.EndColumn;
Block.Columns.push_back(Column);
@@ -179,7 +179,7 @@ public:
else
return Result.takeError();
- Site.Inlinee = IL.Header->Inlinee;
+ Site.Inlinee = IL.Header->Inlinee.getIndex();
Site.SourceLineNum = IL.Header->SourceLineNum;
if (ILF.hasExtraFiles()) {
for (const auto &EF : IL.ExtraFiles) {
@@ -195,17 +195,16 @@ public:
}
private:
-
- llvm::pdb::yaml::PdbSourceFileInfo &Info;
+ CodeViewYAML::SourceFileInfo &Info;
};
}
-Expected<Optional<llvm::pdb::yaml::PdbSourceFileInfo>>
+Expected<Optional<CodeViewYAML::SourceFileInfo>>
YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS) {
if (!ModS.hasLineInfo())
return None;
- yaml::PdbSourceFileInfo Info;
+ CodeViewYAML::SourceFileInfo Info;
C13YamlVisitor Visitor(Info, File);
if (auto EC =
codeview::visitDebugSubsections(ModS.linesAndChecksums(), Visitor))
@@ -357,8 +356,11 @@ Error YAMLOutputStyle::dumpDbiStream() {
DMI.Modi->Signature = ModS.signature();
bool HadError = false;
for (auto &Sym : ModS.symbols(&HadError)) {
- pdb::yaml::PdbSymbolRecord Record{Sym};
- DMI.Modi->Symbols.push_back(Record);
+ auto ES = CodeViewYAML::SymbolRecord::fromCodeViewSymbol(Sym);
+ if (!ES)
+ return ES.takeError();
+
+ DMI.Modi->Symbols.push_back(*ES);
}
}
}
@@ -378,13 +380,10 @@ Error YAMLOutputStyle::dumpTpiStream() {
Obj.TpiStream.emplace();
Obj.TpiStream->Version = TS.getTpiVersion();
for (auto &Record : TS.types(nullptr)) {
- yaml::PdbTpiRecord R;
- // It's not necessary to set R.RecordData here. That only exists as a
- // way to have the `PdbTpiRecord` structure own the memory that `R.Record`
- // references. In the case of reading an existing PDB though, that memory
- // is owned by the backing stream.
- R.Record = Record;
- Obj.TpiStream->Records.push_back(R);
+ auto ExpectedRecord = CodeViewYAML::LeafRecord::fromCodeViewRecord(Record);
+ if (!ExpectedRecord)
+ return ExpectedRecord.takeError();
+ Obj.TpiStream->Records.push_back(*ExpectedRecord);
}
return Error::success();
@@ -402,9 +401,11 @@ Error YAMLOutputStyle::dumpIpiStream() {
Obj.IpiStream.emplace();
Obj.IpiStream->Version = IS.getTpiVersion();
for (auto &Record : IS.types(nullptr)) {
- yaml::PdbTpiRecord R;
- R.Record = Record;
- Obj.IpiStream->Records.push_back(R);
+ auto ExpectedRecord = CodeViewYAML::LeafRecord::fromCodeViewRecord(Record);
+ if (!ExpectedRecord)
+ return ExpectedRecord.takeError();
+
+ Obj.IpiStream->Records.push_back(*ExpectedRecord);
}
return Error::success();
diff --git a/tools/llvm-pdbdump/YAMLOutputStyle.h b/tools/llvm-pdbdump/YAMLOutputStyle.h
index 068312aec450..6e4067c48f88 100644
--- a/tools/llvm-pdbdump/YAMLOutputStyle.h
+++ b/tools/llvm-pdbdump/YAMLOutputStyle.h
@@ -27,7 +27,7 @@ public:
Error dump() override;
private:
- Expected<Optional<llvm::pdb::yaml::PdbSourceFileInfo>>
+ Expected<Optional<CodeViewYAML::SourceFileInfo>>
getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS);
Error dumpStringTable();
diff --git a/tools/llvm-pdbdump/YamlSerializationContext.h b/tools/llvm-pdbdump/YamlSerializationContext.h
deleted file mode 100644
index dcf29d249d60..000000000000
--- a/tools/llvm-pdbdump/YamlSerializationContext.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//===- YamlSerializationContext.h ----------------------------- *- C++ --*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_YAMLSERIALIZATIONCONTEXT_H
-#define LLVM_TOOLS_LLVMPDBDUMP_YAMLSERIALIZATIONCONTEXT_H
-
-#include "PdbYaml.h"
-#include "YamlTypeDumper.h"
-#include "llvm/Support/Allocator.h"
-
-namespace llvm {
-namespace codeview {
-class TypeSerializer;
-}
-namespace yaml {
-class IO;
-}
-
-namespace pdb {
-namespace yaml {
-struct SerializationContext {
- explicit SerializationContext(llvm::yaml::IO &IO, BumpPtrAllocator &Allocator)
- : Dumper(IO, *this), Allocator(Allocator) {}
-
- codeview::yaml::YamlTypeDumperCallbacks Dumper;
- BumpPtrAllocator &Allocator;
- codeview::TypeSerializer *ActiveSerializer = nullptr;
-};
-}
-}
-}
-
-#endif \ No newline at end of file
diff --git a/tools/llvm-pdbdump/YamlSymbolDumper.cpp b/tools/llvm-pdbdump/YamlSymbolDumper.cpp
deleted file mode 100644
index 431bf404fb04..000000000000
--- a/tools/llvm-pdbdump/YamlSymbolDumper.cpp
+++ /dev/null
@@ -1,413 +0,0 @@
-//===- YamlSymbolDumper.cpp ----------------------------------- *- C++ --*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "YamlSymbolDumper.h"
-#include "PdbYaml.h"
-#include "YamlTypeDumper.h"
-
-#include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
-#include "llvm/DebugInfo/CodeView/EnumTables.h"
-#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
-#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
-#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-using namespace llvm::codeview::yaml;
-
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(TypeIndex)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint64_t)
-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::PdbTpiFieldListRecord)
-
-namespace llvm {
-namespace yaml {
-void ScalarEnumerationTraits<SymbolKind>::enumeration(IO &io,
- SymbolKind &Value) {
- auto SymbolNames = getSymbolTypeNames();
- for (const auto &E : SymbolNames)
- io.enumCase(Value, E.Name.str().c_str(), E.Value);
-}
-
-template <> struct ScalarBitSetTraits<CompileSym2Flags> {
- static void bitset(IO &io, CompileSym2Flags &Flags) {
- auto FlagNames = getCompileSym2FlagNames();
- for (const auto &E : FlagNames) {
- io.bitSetCase(Flags, E.Name.str().c_str(),
- static_cast<CompileSym2Flags>(E.Value));
- }
- }
-};
-
-template <> struct ScalarBitSetTraits<CompileSym3Flags> {
- static void bitset(IO &io, CompileSym3Flags &Flags) {
- auto FlagNames = getCompileSym3FlagNames();
- for (const auto &E : FlagNames) {
- io.bitSetCase(Flags, E.Name.str().c_str(),
- static_cast<CompileSym3Flags>(E.Value));
- }
- }
-};
-
-template <> struct ScalarBitSetTraits<ExportFlags> {
- static void bitset(IO &io, ExportFlags &Flags) {
- auto FlagNames = getExportSymFlagNames();
- for (const auto &E : FlagNames) {
- io.bitSetCase(Flags, E.Name.str().c_str(),
- static_cast<ExportFlags>(E.Value));
- }
- }
-};
-
-template <> struct ScalarBitSetTraits<LocalSymFlags> {
- static void bitset(IO &io, LocalSymFlags &Flags) {
- auto FlagNames = getLocalFlagNames();
- for (const auto &E : FlagNames) {
- io.bitSetCase(Flags, E.Name.str().c_str(),
- static_cast<LocalSymFlags>(E.Value));
- }
- }
-};
-
-template <> struct ScalarBitSetTraits<ProcSymFlags> {
- static void bitset(IO &io, ProcSymFlags &Flags) {
- auto FlagNames = getProcSymFlagNames();
- for (const auto &E : FlagNames) {
- io.bitSetCase(Flags, E.Name.str().c_str(),
- static_cast<ProcSymFlags>(E.Value));
- }
- }
-};
-
-template <> struct ScalarBitSetTraits<FrameProcedureOptions> {
- static void bitset(IO &io, FrameProcedureOptions &Flags) {
- auto FlagNames = getFrameProcSymFlagNames();
- for (const auto &E : FlagNames) {
- io.bitSetCase(Flags, E.Name.str().c_str(),
- static_cast<FrameProcedureOptions>(E.Value));
- }
- }
-};
-
-template <> struct ScalarEnumerationTraits<CPUType> {
- static void enumeration(IO &io, CPUType &Cpu) {
- auto CpuNames = getCPUTypeNames();
- for (const auto &E : CpuNames) {
- io.enumCase(Cpu, E.Name.str().c_str(), static_cast<CPUType>(E.Value));
- }
- }
-};
-
-template <> struct ScalarEnumerationTraits<RegisterId> {
- static void enumeration(IO &io, RegisterId &Reg) {
- auto RegNames = getRegisterNames();
- for (const auto &E : RegNames) {
- io.enumCase(Reg, E.Name.str().c_str(), static_cast<RegisterId>(E.Value));
- }
- io.enumFallback<Hex16>(Reg);
- }
-};
-
-template <> struct ScalarEnumerationTraits<TrampolineType> {
- static void enumeration(IO &io, TrampolineType &Tramp) {
- auto TrampNames = getTrampolineNames();
- for (const auto &E : TrampNames) {
- io.enumCase(Tramp, E.Name.str().c_str(),
- static_cast<TrampolineType>(E.Value));
- }
- }
-};
-
-template <> struct ScalarEnumerationTraits<ThunkOrdinal> {
- static void enumeration(IO &io, ThunkOrdinal &Ord) {
- auto ThunkNames = getThunkOrdinalNames();
- for (const auto &E : ThunkNames) {
- io.enumCase(Ord, E.Name.str().c_str(),
- static_cast<ThunkOrdinal>(E.Value));
- }
- }
-};
-
-void MappingTraits<ScopeEndSym>::mapping(IO &IO, ScopeEndSym &Obj) {}
-
-void MappingTraits<Thunk32Sym>::mapping(IO &IO, Thunk32Sym &Thunk) {
- IO.mapRequired("Parent", Thunk.Parent);
- IO.mapRequired("End", Thunk.End);
- IO.mapRequired("Next", Thunk.Next);
- IO.mapRequired("Off", Thunk.Offset);
- IO.mapRequired("Seg", Thunk.Segment);
- IO.mapRequired("Len", Thunk.Length);
- IO.mapRequired("Ordinal", Thunk.Thunk);
-}
-
-void MappingTraits<TrampolineSym>::mapping(IO &IO, TrampolineSym &Tramp) {
- IO.mapRequired("Type", Tramp.Type);
- IO.mapRequired("Size", Tramp.Size);
- IO.mapRequired("ThunkOff", Tramp.ThunkOffset);
- IO.mapRequired("TargetOff", Tramp.TargetOffset);
- IO.mapRequired("ThunkSection", Tramp.ThunkSection);
- IO.mapRequired("TargetSection", Tramp.TargetSection);
-}
-
-void MappingTraits<SectionSym>::mapping(IO &IO, SectionSym &Section) {
- IO.mapRequired("SectionNumber", Section.SectionNumber);
- IO.mapRequired("Alignment", Section.Alignment);
- IO.mapRequired("Rva", Section.Rva);
- IO.mapRequired("Length", Section.Length);
- IO.mapRequired("Characteristics", Section.Characteristics);
- IO.mapRequired("Name", Section.Name);
-}
-
-void MappingTraits<CoffGroupSym>::mapping(IO &IO, CoffGroupSym &CoffGroup) {
- IO.mapRequired("Size", CoffGroup.Size);
- IO.mapRequired("Characteristics", CoffGroup.Characteristics);
- IO.mapRequired("Offset", CoffGroup.Offset);
- IO.mapRequired("Segment", CoffGroup.Segment);
- IO.mapRequired("Name", CoffGroup.Name);
-}
-
-void MappingTraits<ExportSym>::mapping(IO &IO, ExportSym &Export) {
- IO.mapRequired("Ordinal", Export.Ordinal);
- IO.mapRequired("Flags", Export.Flags);
- IO.mapRequired("Name", Export.Name);
-}
-
-void MappingTraits<ProcSym>::mapping(IO &IO, ProcSym &Proc) {
- // TODO: Print the linkage name
-
- IO.mapRequired("PtrParent", Proc.Parent);
- IO.mapRequired("PtrEnd", Proc.End);
- IO.mapRequired("PtrNext", Proc.Next);
- IO.mapRequired("CodeSize", Proc.CodeSize);
- IO.mapRequired("DbgStart", Proc.DbgStart);
- IO.mapRequired("DbgEnd", Proc.DbgEnd);
- IO.mapRequired("FunctionType", Proc.FunctionType);
- IO.mapRequired("Segment", Proc.Segment);
- IO.mapRequired("Flags", Proc.Flags);
- IO.mapRequired("DisplayName", Proc.Name);
-}
-
-void MappingTraits<RegisterSym>::mapping(IO &IO, RegisterSym &Register) {
- IO.mapRequired("Type", Register.Index);
- IO.mapRequired("Seg", Register.Register);
- IO.mapRequired("Name", Register.Name);
-}
-
-void MappingTraits<PublicSym32>::mapping(IO &IO, PublicSym32 &Public) {
- IO.mapRequired("Type", Public.Index);
- IO.mapRequired("Seg", Public.Segment);
- IO.mapRequired("Off", Public.Offset);
- IO.mapRequired("Name", Public.Name);
-}
-
-void MappingTraits<ProcRefSym>::mapping(IO &IO, ProcRefSym &ProcRef) {
- IO.mapRequired("SumName", ProcRef.SumName);
- IO.mapRequired("SymOffset", ProcRef.SymOffset);
- IO.mapRequired("Mod", ProcRef.Module);
- IO.mapRequired("Name", ProcRef.Name);
-}
-
-void MappingTraits<EnvBlockSym>::mapping(IO &IO, EnvBlockSym &EnvBlock) {
- IO.mapRequired("Entries", EnvBlock.Fields);
-}
-
-void MappingTraits<InlineSiteSym>::mapping(IO &IO, InlineSiteSym &InlineSite) {
- IO.mapRequired("PtrParent", InlineSite.Parent);
- IO.mapRequired("PtrEnd", InlineSite.End);
- IO.mapRequired("Inlinee", InlineSite.Inlinee);
- // TODO: The binary annotations
-}
-
-void MappingTraits<LocalSym>::mapping(IO &IO, LocalSym &Local) {
- IO.mapRequired("Type", Local.Type);
- IO.mapRequired("Flags", Local.Flags);
- IO.mapRequired("VarName", Local.Name);
-}
-
-void MappingTraits<DefRangeSym>::mapping(IO &IO, DefRangeSym &Obj) {
- // TODO: Print the subfields
-}
-
-void MappingTraits<DefRangeSubfieldSym>::mapping(IO &IO,
- DefRangeSubfieldSym &Obj) {
- // TODO: Print the subfields
-}
-
-void MappingTraits<DefRangeRegisterSym>::mapping(IO &IO,
- DefRangeRegisterSym &Obj) {
- // TODO: Print the subfields
-}
-
-void MappingTraits<DefRangeFramePointerRelSym>::mapping(
- IO &IO, DefRangeFramePointerRelSym &Obj) {
- // TODO: Print the subfields
-}
-
-void MappingTraits<DefRangeSubfieldRegisterSym>::mapping(
- IO &IO, DefRangeSubfieldRegisterSym &Obj) {
- // TODO: Print the subfields
-}
-
-void MappingTraits<DefRangeFramePointerRelFullScopeSym>::mapping(
- IO &IO, DefRangeFramePointerRelFullScopeSym &Obj) {
- // TODO: Print the subfields
-}
-
-void MappingTraits<DefRangeRegisterRelSym>::mapping(
- IO &IO, DefRangeRegisterRelSym &Obj) {
- // TODO: Print the subfields
-}
-
-void MappingTraits<BlockSym>::mapping(IO &IO, BlockSym &Block) {
- // TODO: Print the linkage name
- IO.mapRequired("PtrParent", Block.Parent);
- IO.mapRequired("PtrEnd", Block.End);
- IO.mapRequired("CodeSize", Block.CodeSize);
- IO.mapRequired("Segment", Block.Segment);
- IO.mapRequired("BlockName", Block.Name);
-}
-
-void MappingTraits<LabelSym>::mapping(IO &IO, LabelSym &Label) {
- // TODO: Print the linkage name
- IO.mapRequired("Segment", Label.Segment);
- IO.mapRequired("Flags", Label.Flags);
- IO.mapRequired("Flags", Label.Flags);
- IO.mapRequired("DisplayName", Label.Name);
-}
-
-void MappingTraits<ObjNameSym>::mapping(IO &IO, ObjNameSym &ObjName) {
- IO.mapRequired("Signature", ObjName.Signature);
- IO.mapRequired("ObjectName", ObjName.Name);
-}
-
-void MappingTraits<Compile2Sym>::mapping(IO &IO, Compile2Sym &Compile2) {
- IO.mapRequired("Flags", Compile2.Flags);
- IO.mapRequired("Machine", Compile2.Machine);
- IO.mapRequired("FrontendMajor", Compile2.VersionFrontendMajor);
- IO.mapRequired("FrontendMinor", Compile2.VersionFrontendMinor);
- IO.mapRequired("FrontendBuild", Compile2.VersionFrontendBuild);
- IO.mapRequired("BackendMajor", Compile2.VersionBackendMajor);
- IO.mapRequired("BackendMinor", Compile2.VersionBackendMinor);
- IO.mapRequired("BackendBuild", Compile2.VersionBackendBuild);
- IO.mapRequired("Version", Compile2.Version);
-}
-
-void MappingTraits<Compile3Sym>::mapping(IO &IO, Compile3Sym &Compile3) {
- IO.mapRequired("Flags", Compile3.Flags);
- IO.mapRequired("Machine", Compile3.Machine);
- IO.mapRequired("FrontendMajor", Compile3.VersionFrontendMajor);
- IO.mapRequired("FrontendMinor", Compile3.VersionFrontendMinor);
- IO.mapRequired("FrontendBuild", Compile3.VersionFrontendBuild);
- IO.mapRequired("FrontendQFE", Compile3.VersionFrontendQFE);
- IO.mapRequired("BackendMajor", Compile3.VersionBackendMajor);
- IO.mapRequired("BackendMinor", Compile3.VersionBackendMinor);
- IO.mapRequired("BackendBuild", Compile3.VersionBackendBuild);
- IO.mapRequired("BackendQFE", Compile3.VersionBackendQFE);
- IO.mapRequired("Version", Compile3.Version);
-}
-
-void MappingTraits<FrameProcSym>::mapping(IO &IO, FrameProcSym &FrameProc) {
- IO.mapRequired("TotalFrameBytes", FrameProc.TotalFrameBytes);
- IO.mapRequired("PaddingFrameBytes", FrameProc.PaddingFrameBytes);
- IO.mapRequired("OffsetToPadding", FrameProc.OffsetToPadding);
- IO.mapRequired("BytesOfCalleeSavedRegisters",
- FrameProc.BytesOfCalleeSavedRegisters);
- IO.mapRequired("OffsetOfExceptionHandler",
- FrameProc.OffsetOfExceptionHandler);
- IO.mapRequired("SectionIdOfExceptionHandler",
- FrameProc.SectionIdOfExceptionHandler);
- IO.mapRequired("Flags", FrameProc.Flags);
-}
-
-void MappingTraits<CallSiteInfoSym>::mapping(IO &IO,
- CallSiteInfoSym &CallSiteInfo) {
- // TODO: Map Linkage Name
- IO.mapRequired("Segment", CallSiteInfo.Segment);
- IO.mapRequired("Type", CallSiteInfo.Type);
-}
-
-void MappingTraits<FileStaticSym>::mapping(IO &IO, FileStaticSym &FileStatic) {
- IO.mapRequired("Index", FileStatic.Index);
- IO.mapRequired("ModFilenameOffset", FileStatic.ModFilenameOffset);
- IO.mapRequired("Flags", FileStatic.Flags);
- IO.mapRequired("Name", FileStatic.Name);
-}
-
-void MappingTraits<HeapAllocationSiteSym>::mapping(
- IO &IO, HeapAllocationSiteSym &HeapAllocSite) {
- // TODO: Map Linkage Name
- IO.mapRequired("Segment", HeapAllocSite.Segment);
- IO.mapRequired("CallInstructionSize", HeapAllocSite.CallInstructionSize);
- IO.mapRequired("Type", HeapAllocSite.Type);
-}
-
-void MappingTraits<FrameCookieSym>::mapping(IO &IO,
- FrameCookieSym &FrameCookie) {
- // TODO: Map Linkage Name
- IO.mapRequired("Register", FrameCookie.Register);
- IO.mapRequired("CookieKind", FrameCookie.CookieKind);
- IO.mapRequired("Flags", FrameCookie.Flags);
-}
-
-void MappingTraits<CallerSym>::mapping(IO &IO, CallerSym &Caller) {
- // TODO: Correctly handle the ArrayRef in here.
- std::vector<TypeIndex> Indices(Caller.Indices);
- IO.mapRequired("FuncID", Indices);
-}
-
-void MappingTraits<UDTSym>::mapping(IO &IO, UDTSym &UDT) {
- IO.mapRequired("Type", UDT.Type);
- IO.mapRequired("UDTName", UDT.Name);
-}
-
-void MappingTraits<BuildInfoSym>::mapping(IO &IO, BuildInfoSym &BuildInfo) {
- IO.mapRequired("BuildId", BuildInfo.BuildId);
-}
-
-void MappingTraits<BPRelativeSym>::mapping(IO &IO, BPRelativeSym &BPRel) {
- IO.mapRequired("Offset", BPRel.Offset);
- IO.mapRequired("Type", BPRel.Type);
- IO.mapRequired("VarName", BPRel.Name);
-}
-
-void MappingTraits<RegRelativeSym>::mapping(IO &IO, RegRelativeSym &RegRel) {
- IO.mapRequired("Offset", RegRel.Offset);
- IO.mapRequired("Type", RegRel.Type);
- IO.mapRequired("Register", RegRel.Register);
- IO.mapRequired("VarName", RegRel.Name);
-}
-
-void MappingTraits<ConstantSym>::mapping(IO &IO, ConstantSym &Constant) {
- IO.mapRequired("Type", Constant.Type);
- IO.mapRequired("Value", Constant.Value);
- IO.mapRequired("Name", Constant.Name);
-}
-
-void MappingTraits<DataSym>::mapping(IO &IO, DataSym &Data) {
- // TODO: Map linkage name
- IO.mapRequired("Type", Data.Type);
- IO.mapRequired("DisplayName", Data.Name);
-}
-
-void MappingTraits<ThreadLocalDataSym>::mapping(IO &IO,
- ThreadLocalDataSym &Data) {
- // TODO: Map linkage name
- IO.mapRequired("Type", Data.Type);
- IO.mapRequired("DisplayName", Data.Name);
-}
-}
-}
-
-Error llvm::codeview::yaml::YamlSymbolDumper::visitSymbolBegin(CVSymbol &CVR) {
- YamlIO.mapRequired("Kind", CVR.Type);
- return Error::success();
-}
diff --git a/tools/llvm-pdbdump/YamlSymbolDumper.h b/tools/llvm-pdbdump/YamlSymbolDumper.h
deleted file mode 100644
index 61e63f96719a..000000000000
--- a/tools/llvm-pdbdump/YamlSymbolDumper.h
+++ /dev/null
@@ -1,66 +0,0 @@
-//===- YamlSymbolDumper.h ------------------------------------- *- C++ --*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_YAMLSYMBOLDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_YAMLSYMBOLDUMPER_H
-
-#include "llvm/DebugInfo/CodeView/CodeView.h"
-#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
-#include "llvm/Support/YAMLTraits.h"
-
-namespace llvm {
-namespace pdb {
-namespace yaml {
-struct SerializationContext;
-}
-}
-namespace codeview {
-namespace yaml {
-class YamlSymbolDumper : public SymbolVisitorCallbacks {
-public:
- YamlSymbolDumper(llvm::yaml::IO &IO) : YamlIO(IO) {}
-
- virtual Error visitSymbolBegin(CVSymbol &Record) override;
-
-#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
- Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \
- visitKnownRecordImpl(#Name, CVR, Record); \
- return Error::success(); \
- }
-#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#include "llvm/DebugInfo/CodeView/CVSymbolTypes.def"
-
-private:
- template <typename T>
- void visitKnownRecordImpl(const char *Name, CVSymbol &Type, T &Record) {
- YamlIO.mapRequired(Name, Record);
- }
-
- llvm::yaml::IO &YamlIO;
-};
-}
-}
-}
-
-namespace llvm {
-namespace yaml {
-template <> struct ScalarEnumerationTraits<codeview::SymbolKind> {
- static void enumeration(IO &io, codeview::SymbolKind &Value);
-};
-
-#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
- template <> struct MappingTraits<codeview::Name> { \
- static void mapping(IO &IO, codeview::Name &Obj); \
- };
-#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#include "llvm/DebugInfo/CodeView/CVSymbolTypes.def"
-}
-}
-
-#endif
diff --git a/tools/llvm-pdbdump/YamlTypeDumper.cpp b/tools/llvm-pdbdump/YamlTypeDumper.cpp
deleted file mode 100644
index beb700720954..000000000000
--- a/tools/llvm-pdbdump/YamlTypeDumper.cpp
+++ /dev/null
@@ -1,589 +0,0 @@
-//===- YamlTypeDumper.cpp ------------------------------------- *- C++ --*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "YamlTypeDumper.h"
-#include "PdbYaml.h"
-#include "YamlSerializationContext.h"
-
-#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
-#include "llvm/DebugInfo/CodeView/EnumTables.h"
-#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeSerializer.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
-#include "llvm/DebugInfo/PDB/Native/TpiHashing.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-using namespace llvm::codeview::yaml;
-
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(TypeIndex)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint64_t)
-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::PdbTpiFieldListRecord)
-
-namespace {
-struct FieldListRecordSplitter : public TypeVisitorCallbacks {
-public:
- explicit FieldListRecordSplitter(
- std::vector<llvm::pdb::yaml::PdbTpiFieldListRecord> &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 visitKnownMember(CVMemberRecord &CVT, Name##Record &Record) override { \
- visitKnownMemberImpl(CVT); \
- return Error::success(); \
- }
-#include "llvm/DebugInfo/CodeView/TypeRecords.def"
-
-private:
- void visitKnownMemberImpl(CVMemberRecord &CVT) {
- llvm::pdb::yaml::PdbTpiFieldListRecord R;
- R.Record = CVT;
- Records.push_back(std::move(R));
- }
-
- std::vector<llvm::pdb::yaml::PdbTpiFieldListRecord> &Records;
-};
-}
-
-namespace llvm {
-namespace yaml {
-template <> struct ScalarEnumerationTraits<PointerToMemberRepresentation> {
- static void enumeration(IO &IO, PointerToMemberRepresentation &Value) {
- IO.enumCase(Value, "Unknown", PointerToMemberRepresentation::Unknown);
- IO.enumCase(Value, "SingleInheritanceData",
- PointerToMemberRepresentation::SingleInheritanceData);
- IO.enumCase(Value, "MultipleInheritanceData",
- PointerToMemberRepresentation::MultipleInheritanceData);
- IO.enumCase(Value, "VirtualInheritanceData",
- PointerToMemberRepresentation::VirtualInheritanceData);
- IO.enumCase(Value, "GeneralData",
- PointerToMemberRepresentation::GeneralData);
- IO.enumCase(Value, "SingleInheritanceFunction",
- PointerToMemberRepresentation::SingleInheritanceFunction);
- IO.enumCase(Value, "MultipleInheritanceFunction",
- PointerToMemberRepresentation::MultipleInheritanceFunction);
- IO.enumCase(Value, "VirtualInheritanceFunction",
- PointerToMemberRepresentation::VirtualInheritanceFunction);
- IO.enumCase(Value, "GeneralFunction",
- PointerToMemberRepresentation::GeneralFunction);
- }
-};
-
-template <> struct ScalarEnumerationTraits<VFTableSlotKind> {
- static void enumeration(IO &IO, VFTableSlotKind &Kind) {
- IO.enumCase(Kind, "Near16", VFTableSlotKind::Near16);
- IO.enumCase(Kind, "Far16", VFTableSlotKind::Far16);
- IO.enumCase(Kind, "This", VFTableSlotKind::This);
- IO.enumCase(Kind, "Outer", VFTableSlotKind::Outer);
- IO.enumCase(Kind, "Meta", VFTableSlotKind::Meta);
- IO.enumCase(Kind, "Near", VFTableSlotKind::Near);
- IO.enumCase(Kind, "Far", VFTableSlotKind::Far);
- }
-};
-
-template <> struct ScalarEnumerationTraits<CallingConvention> {
- static void enumeration(IO &IO, CallingConvention &Value) {
- IO.enumCase(Value, "NearC", CallingConvention::NearC);
- IO.enumCase(Value, "FarC", CallingConvention::FarC);
- IO.enumCase(Value, "NearPascal", CallingConvention::NearPascal);
- IO.enumCase(Value, "FarPascal", CallingConvention::FarPascal);
- IO.enumCase(Value, "NearFast", CallingConvention::NearFast);
- IO.enumCase(Value, "FarFast", CallingConvention::FarFast);
- IO.enumCase(Value, "NearStdCall", CallingConvention::NearStdCall);
- IO.enumCase(Value, "FarStdCall", CallingConvention::FarStdCall);
- IO.enumCase(Value, "NearSysCall", CallingConvention::NearSysCall);
- IO.enumCase(Value, "FarSysCall", CallingConvention::FarSysCall);
- IO.enumCase(Value, "ThisCall", CallingConvention::ThisCall);
- IO.enumCase(Value, "MipsCall", CallingConvention::MipsCall);
- IO.enumCase(Value, "Generic", CallingConvention::Generic);
- IO.enumCase(Value, "AlphaCall", CallingConvention::AlphaCall);
- IO.enumCase(Value, "PpcCall", CallingConvention::PpcCall);
- IO.enumCase(Value, "SHCall", CallingConvention::SHCall);
- IO.enumCase(Value, "ArmCall", CallingConvention::ArmCall);
- IO.enumCase(Value, "AM33Call", CallingConvention::AM33Call);
- IO.enumCase(Value, "TriCall", CallingConvention::TriCall);
- IO.enumCase(Value, "SH5Call", CallingConvention::SH5Call);
- IO.enumCase(Value, "M32RCall", CallingConvention::M32RCall);
- IO.enumCase(Value, "ClrCall", CallingConvention::ClrCall);
- IO.enumCase(Value, "Inline", CallingConvention::Inline);
- IO.enumCase(Value, "NearVector", CallingConvention::NearVector);
- }
-};
-
-template <> struct ScalarEnumerationTraits<PointerKind> {
- static void enumeration(IO &IO, PointerKind &Kind) {
- IO.enumCase(Kind, "Near16", PointerKind::Near16);
- IO.enumCase(Kind, "Far16", PointerKind::Far16);
- IO.enumCase(Kind, "Huge16", PointerKind::Huge16);
- IO.enumCase(Kind, "BasedOnSegment", PointerKind::BasedOnSegment);
- IO.enumCase(Kind, "BasedOnValue", PointerKind::BasedOnValue);
- IO.enumCase(Kind, "BasedOnSegmentValue", PointerKind::BasedOnSegmentValue);
- IO.enumCase(Kind, "BasedOnAddress", PointerKind::BasedOnAddress);
- IO.enumCase(Kind, "BasedOnSegmentAddress",
- PointerKind::BasedOnSegmentAddress);
- IO.enumCase(Kind, "BasedOnType", PointerKind::BasedOnType);
- IO.enumCase(Kind, "BasedOnSelf", PointerKind::BasedOnSelf);
- IO.enumCase(Kind, "Near32", PointerKind::Near32);
- IO.enumCase(Kind, "Far32", PointerKind::Far32);
- IO.enumCase(Kind, "Near64", PointerKind::Near64);
- }
-};
-
-template <> struct ScalarEnumerationTraits<PointerMode> {
- static void enumeration(IO &IO, PointerMode &Mode) {
- IO.enumCase(Mode, "Pointer", PointerMode::Pointer);
- IO.enumCase(Mode, "LValueReference", PointerMode::LValueReference);
- IO.enumCase(Mode, "PointerToDataMember", PointerMode::PointerToDataMember);
- IO.enumCase(Mode, "PointerToMemberFunction",
- PointerMode::PointerToMemberFunction);
- IO.enumCase(Mode, "RValueReference", PointerMode::RValueReference);
- }
-};
-
-template <> struct ScalarEnumerationTraits<HfaKind> {
- static void enumeration(IO &IO, HfaKind &Value) {
- IO.enumCase(Value, "None", HfaKind::None);
- IO.enumCase(Value, "Float", HfaKind::Float);
- IO.enumCase(Value, "Double", HfaKind::Double);
- IO.enumCase(Value, "Other", HfaKind::Other);
- }
-};
-
-template <> struct ScalarEnumerationTraits<MemberAccess> {
- static void enumeration(IO &IO, MemberAccess &Access) {
- IO.enumCase(Access, "None", MemberAccess::None);
- IO.enumCase(Access, "Private", MemberAccess::Private);
- IO.enumCase(Access, "Protected", MemberAccess::Protected);
- IO.enumCase(Access, "Public", MemberAccess::Public);
- }
-};
-
-template <> struct ScalarEnumerationTraits<MethodKind> {
- static void enumeration(IO &IO, MethodKind &Kind) {
- IO.enumCase(Kind, "Vanilla", MethodKind::Vanilla);
- IO.enumCase(Kind, "Virtual", MethodKind::Virtual);
- IO.enumCase(Kind, "Static", MethodKind::Static);
- IO.enumCase(Kind, "Friend", MethodKind::Friend);
- IO.enumCase(Kind, "IntroducingVirtual", MethodKind::IntroducingVirtual);
- IO.enumCase(Kind, "PureVirtual", MethodKind::PureVirtual);
- IO.enumCase(Kind, "PureIntroducingVirtual",
- MethodKind::PureIntroducingVirtual);
- }
-};
-
-template <> struct ScalarEnumerationTraits<WindowsRTClassKind> {
- static void enumeration(IO &IO, WindowsRTClassKind &Value) {
- IO.enumCase(Value, "None", WindowsRTClassKind::None);
- IO.enumCase(Value, "Ref", WindowsRTClassKind::RefClass);
- IO.enumCase(Value, "Value", WindowsRTClassKind::ValueClass);
- IO.enumCase(Value, "Interface", WindowsRTClassKind::Interface);
- }
-};
-
-template <> struct ScalarEnumerationTraits<LabelType> {
- static void enumeration(IO &IO, LabelType &Value) {
- IO.enumCase(Value, "Near", LabelType::Near);
- IO.enumCase(Value, "Far", LabelType::Far);
- }
-};
-
-template <> struct ScalarBitSetTraits<PointerOptions> {
- static void bitset(IO &IO, PointerOptions &Options) {
- IO.bitSetCase(Options, "None", PointerOptions::None);
- IO.bitSetCase(Options, "Flat32", PointerOptions::Flat32);
- IO.bitSetCase(Options, "Volatile", PointerOptions::Volatile);
- IO.bitSetCase(Options, "Const", PointerOptions::Const);
- IO.bitSetCase(Options, "Unaligned", PointerOptions::Unaligned);
- IO.bitSetCase(Options, "Restrict", PointerOptions::Restrict);
- IO.bitSetCase(Options, "WinRTSmartPointer",
- PointerOptions::WinRTSmartPointer);
- }
-};
-
-template <> struct ScalarBitSetTraits<ModifierOptions> {
- static void bitset(IO &IO, ModifierOptions &Options) {
- IO.bitSetCase(Options, "None", ModifierOptions::None);
- IO.bitSetCase(Options, "Const", ModifierOptions::Const);
- IO.bitSetCase(Options, "Volatile", ModifierOptions::Volatile);
- IO.bitSetCase(Options, "Unaligned", ModifierOptions::Unaligned);
- }
-};
-
-template <> struct ScalarBitSetTraits<FunctionOptions> {
- static void bitset(IO &IO, FunctionOptions &Options) {
- IO.bitSetCase(Options, "None", FunctionOptions::None);
- IO.bitSetCase(Options, "CxxReturnUdt", FunctionOptions::CxxReturnUdt);
- IO.bitSetCase(Options, "Constructor", FunctionOptions::Constructor);
- IO.bitSetCase(Options, "ConstructorWithVirtualBases",
- FunctionOptions::ConstructorWithVirtualBases);
- }
-};
-
-template <> struct ScalarBitSetTraits<ClassOptions> {
- static void bitset(IO &IO, ClassOptions &Options) {
- IO.bitSetCase(Options, "None", ClassOptions::None);
- IO.bitSetCase(Options, "HasConstructorOrDestructor",
- ClassOptions::HasConstructorOrDestructor);
- IO.bitSetCase(Options, "HasOverloadedOperator",
- ClassOptions::HasOverloadedOperator);
- IO.bitSetCase(Options, "Nested", ClassOptions::Nested);
- IO.bitSetCase(Options, "ContainsNestedClass",
- ClassOptions::ContainsNestedClass);
- IO.bitSetCase(Options, "HasOverloadedAssignmentOperator",
- ClassOptions::HasOverloadedAssignmentOperator);
- IO.bitSetCase(Options, "HasConversionOperator",
- ClassOptions::HasConversionOperator);
- IO.bitSetCase(Options, "ForwardReference", ClassOptions::ForwardReference);
- IO.bitSetCase(Options, "Scoped", ClassOptions::Scoped);
- IO.bitSetCase(Options, "HasUniqueName", ClassOptions::HasUniqueName);
- IO.bitSetCase(Options, "Sealed", ClassOptions::Sealed);
- IO.bitSetCase(Options, "Intrinsic", ClassOptions::Intrinsic);
- }
-};
-
-template <> struct ScalarBitSetTraits<MethodOptions> {
- static void bitset(IO &IO, MethodOptions &Options) {
- IO.bitSetCase(Options, "None", MethodOptions::None);
- IO.bitSetCase(Options, "Pseudo", MethodOptions::Pseudo);
- IO.bitSetCase(Options, "NoInherit", MethodOptions::NoInherit);
- IO.bitSetCase(Options, "NoConstruct", MethodOptions::NoConstruct);
- IO.bitSetCase(Options, "CompilerGenerated",
- MethodOptions::CompilerGenerated);
- IO.bitSetCase(Options, "Sealed", MethodOptions::Sealed);
- }
-};
-
-void ScalarTraits<APSInt>::output(const APSInt &S, void *,
- llvm::raw_ostream &OS) {
- S.print(OS, true);
-}
-StringRef ScalarTraits<APSInt>::input(StringRef Scalar, void *Ctx, APSInt &S) {
- S = APSInt(Scalar);
- return "";
-}
-
-bool ScalarTraits<APSInt>::mustQuote(StringRef Scalar) { return false; }
-
-void MappingContextTraits<CVType, pdb::yaml::SerializationContext>::mapping(
- IO &IO, CVType &Record, pdb::yaml::SerializationContext &Context) {
- if (IO.outputting())
- consumeError(codeview::visitTypeRecord(Record, Context.Dumper));
-}
-
-void MappingTraits<StringIdRecord>::mapping(IO &IO, StringIdRecord &String) {
- IO.mapRequired("Id", String.Id);
- IO.mapRequired("String", String.String);
-}
-
-void MappingTraits<ArgListRecord>::mapping(IO &IO, ArgListRecord &Args) {
- IO.mapRequired("ArgIndices", Args.ArgIndices);
-}
-
-void MappingTraits<StringListRecord>::mapping(IO &IO, StringListRecord &Strings) {
- IO.mapRequired("StringIndices", Strings.StringIndices);
-}
-
-void MappingTraits<ClassRecord>::mapping(IO &IO, ClassRecord &Class) {
- IO.mapRequired("MemberCount", Class.MemberCount);
- IO.mapRequired("Options", Class.Options);
- IO.mapRequired("FieldList", Class.FieldList);
- IO.mapRequired("Name", Class.Name);
- IO.mapRequired("UniqueName", Class.UniqueName);
- IO.mapRequired("DerivationList", Class.DerivationList);
- IO.mapRequired("VTableShape", Class.VTableShape);
- IO.mapRequired("Size", Class.Size);
-}
-
-void MappingTraits<UnionRecord>::mapping(IO &IO, UnionRecord &Union) {
- IO.mapRequired("MemberCount", Union.MemberCount);
- IO.mapRequired("Options", Union.Options);
- IO.mapRequired("FieldList", Union.FieldList);
- IO.mapRequired("Name", Union.Name);
- IO.mapRequired("UniqueName", Union.UniqueName);
- IO.mapRequired("Size", Union.Size);
-}
-
-void MappingTraits<EnumRecord>::mapping(IO &IO, EnumRecord &Enum) {
- IO.mapRequired("NumEnumerators", Enum.MemberCount);
- IO.mapRequired("Options", Enum.Options);
- IO.mapRequired("FieldList", Enum.FieldList);
- IO.mapRequired("Name", Enum.Name);
- IO.mapRequired("UniqueName", Enum.UniqueName);
- IO.mapRequired("UnderlyingType", Enum.UnderlyingType);
-}
-
-void MappingTraits<ArrayRecord>::mapping(IO &IO, ArrayRecord &AT) {
- IO.mapRequired("ElementType", AT.ElementType);
- IO.mapRequired("IndexType", AT.IndexType);
- IO.mapRequired("Size", AT.Size);
- IO.mapRequired("Name", AT.Name);
-}
-
-void MappingTraits<VFTableRecord>::mapping(IO &IO, VFTableRecord &VFT) {
- IO.mapRequired("CompleteClass", VFT.CompleteClass);
- IO.mapRequired("OverriddenVFTable", VFT.OverriddenVFTable);
- IO.mapRequired("VFPtrOffset", VFT.VFPtrOffset);
- IO.mapRequired("MethodNames", VFT.MethodNames);
-}
-
-void MappingTraits<MemberFuncIdRecord>::mapping(IO &IO,
- MemberFuncIdRecord &Id) {
- IO.mapRequired("ClassType", Id.ClassType);
- IO.mapRequired("FunctionType", Id.FunctionType);
- IO.mapRequired("Name", Id.Name);
-}
-
-void MappingTraits<ProcedureRecord>::mapping(IO &IO, ProcedureRecord &Proc) {
- IO.mapRequired("ReturnType", Proc.ReturnType);
- IO.mapRequired("CallConv", Proc.CallConv);
- IO.mapRequired("Options", Proc.Options);
- IO.mapRequired("ParameterCount", Proc.ParameterCount);
- IO.mapRequired("ArgumentList", Proc.ArgumentList);
-}
-
-void MappingTraits<MemberFunctionRecord>::mapping(IO &IO,
- MemberFunctionRecord &MF) {
- IO.mapRequired("ReturnType", MF.ReturnType);
- IO.mapRequired("ClassType", MF.ClassType);
- IO.mapRequired("ThisType", MF.ThisType);
- IO.mapRequired("CallConv", MF.CallConv);
- IO.mapRequired("Options", MF.Options);
- IO.mapRequired("ParameterCount", MF.ParameterCount);
- IO.mapRequired("ArgumentList", MF.ArgumentList);
- IO.mapRequired("ThisPointerAdjustment", MF.ThisPointerAdjustment);
-}
-
-void MappingTraits<MethodOverloadListRecord>::mapping(
- IO &IO, MethodOverloadListRecord &MethodList) {
- IO.mapRequired("Methods", MethodList.Methods);
-}
-
-void MappingTraits<FuncIdRecord>::mapping(IO &IO, FuncIdRecord &Func) {
- IO.mapRequired("ParentScope", Func.ParentScope);
- IO.mapRequired("FunctionType", Func.FunctionType);
- IO.mapRequired("Name", Func.Name);
-}
-
-void MappingTraits<TypeServer2Record>::mapping(IO &IO, TypeServer2Record &TS) {
- IO.mapRequired("Guid", TS.Guid);
- IO.mapRequired("Age", TS.Age);
- IO.mapRequired("Name", TS.Name);
-}
-
-void MappingTraits<PointerRecord>::mapping(IO &IO, PointerRecord &Ptr) {
- IO.mapRequired("ReferentType", Ptr.ReferentType);
- IO.mapRequired("Attrs", Ptr.Attrs);
- IO.mapOptional("MemberInfo", Ptr.MemberInfo);
-}
-
-void MappingTraits<MemberPointerInfo>::mapping(IO &IO, MemberPointerInfo &MPI) {
- IO.mapRequired("ContainingType", MPI.ContainingType);
- IO.mapRequired("Representation", MPI.Representation);
-}
-
-void MappingTraits<ModifierRecord>::mapping(IO &IO, ModifierRecord &Mod) {
- IO.mapRequired("ModifiedType", Mod.ModifiedType);
- IO.mapRequired("Modifiers", Mod.Modifiers);
-}
-
-void MappingTraits<BitFieldRecord>::mapping(IO &IO, BitFieldRecord &BitField) {
- IO.mapRequired("Type", BitField.Type);
- IO.mapRequired("BitSize", BitField.BitSize);
- IO.mapRequired("BitOffset", BitField.BitOffset);
-}
-
-void MappingTraits<VFTableShapeRecord>::mapping(IO &IO,
- VFTableShapeRecord &Shape) {
- IO.mapRequired("Slots", Shape.Slots);
-}
-
-void MappingTraits<UdtSourceLineRecord>::mapping(IO &IO,
- UdtSourceLineRecord &Line) {
- IO.mapRequired("UDT", Line.UDT);
- IO.mapRequired("SourceFile", Line.SourceFile);
- IO.mapRequired("LineNumber", Line.LineNumber);
-}
-
-void MappingTraits<UdtModSourceLineRecord>::mapping(
- IO &IO, UdtModSourceLineRecord &Line) {
- IO.mapRequired("UDT", Line.UDT);
- IO.mapRequired("SourceFile", Line.SourceFile);
- IO.mapRequired("LineNumber", Line.LineNumber);
- IO.mapRequired("Module", Line.Module);
-}
-
-void MappingTraits<BuildInfoRecord>::mapping(IO &IO, BuildInfoRecord &Args) {
- IO.mapRequired("ArgIndices", Args.ArgIndices);
-}
-
-void MappingTraits<LabelRecord>::mapping(IO &IO, LabelRecord &R) {
- IO.mapRequired("Mode", R.Mode);
-}
-
-void MappingTraits<NestedTypeRecord>::mapping(IO &IO,
- NestedTypeRecord &Nested) {
- IO.mapRequired("Type", Nested.Type);
- IO.mapRequired("Name", Nested.Name);
-}
-
-void MappingTraits<OneMethodRecord>::mapping(IO &IO, OneMethodRecord &Method) {
- IO.mapRequired("Type", Method.Type);
- IO.mapRequired("Attrs", Method.Attrs.Attrs);
- IO.mapRequired("VFTableOffset", Method.VFTableOffset);
- IO.mapRequired("Name", Method.Name);
-}
-
-void MappingTraits<OverloadedMethodRecord>::mapping(
- IO &IO, OverloadedMethodRecord &Method) {
- IO.mapRequired("NumOverloads", Method.NumOverloads);
- IO.mapRequired("MethodList", Method.MethodList);
- IO.mapRequired("Name", Method.Name);
-}
-
-void MappingTraits<DataMemberRecord>::mapping(IO &IO, DataMemberRecord &Field) {
- IO.mapRequired("Attrs", Field.Attrs.Attrs);
- IO.mapRequired("Type", Field.Type);
- IO.mapRequired("FieldOffset", Field.FieldOffset);
- IO.mapRequired("Name", Field.Name);
-}
-
-void MappingTraits<StaticDataMemberRecord>::mapping(
- IO &IO, StaticDataMemberRecord &Field) {
- IO.mapRequired("Attrs", Field.Attrs.Attrs);
- IO.mapRequired("Type", Field.Type);
- IO.mapRequired("Name", Field.Name);
-}
-
-void MappingTraits<VFPtrRecord>::mapping(IO &IO, VFPtrRecord &VFTable) {
- IO.mapRequired("Type", VFTable.Type);
-}
-
-void MappingTraits<EnumeratorRecord>::mapping(IO &IO, EnumeratorRecord &Enum) {
- IO.mapRequired("Attrs", Enum.Attrs.Attrs);
- IO.mapRequired("Value", Enum.Value);
- IO.mapRequired("Name", Enum.Name);
-}
-
-void MappingTraits<BaseClassRecord>::mapping(IO &IO, BaseClassRecord &Base) {
- IO.mapRequired("Attrs", Base.Attrs.Attrs);
- IO.mapRequired("Type", Base.Type);
- IO.mapRequired("Offset", Base.Offset);
-}
-
-void MappingTraits<VirtualBaseClassRecord>::mapping(
- IO &IO, VirtualBaseClassRecord &Base) {
- IO.mapRequired("Attrs", Base.Attrs.Attrs);
- IO.mapRequired("BaseType", Base.BaseType);
- IO.mapRequired("VBPtrType", Base.VBPtrType);
- IO.mapRequired("VBPtrOffset", Base.VBPtrOffset);
- IO.mapRequired("VTableIndex", Base.VTableIndex);
-}
-
-void MappingTraits<ListContinuationRecord>::mapping(
- IO &IO, ListContinuationRecord &Cont) {
- IO.mapRequired("ContinuationIndex", Cont.ContinuationIndex);
-}
-
-void ScalarTraits<codeview::TypeIndex>::output(const codeview::TypeIndex &S,
- void *, llvm::raw_ostream &OS) {
- OS << S.getIndex();
-}
-StringRef ScalarTraits<codeview::TypeIndex>::input(StringRef Scalar, void *Ctx,
- codeview::TypeIndex &S) {
- uint32_t I;
- StringRef Result = ScalarTraits<uint32_t>::input(Scalar, Ctx, I);
- if (!Result.empty())
- return Result;
- S = TypeIndex(I);
- return "";
-}
-bool ScalarTraits<codeview::TypeIndex>::mustQuote(StringRef Scalar) {
- return false;
-}
-
-void ScalarEnumerationTraits<TypeLeafKind>::enumeration(IO &io,
- TypeLeafKind &Value) {
- auto TypeLeafNames = getTypeLeafNames();
- for (const auto &E : TypeLeafNames)
- io.enumCase(Value, E.Name.str().c_str(), E.Value);
-}
-}
-}
-
-Error llvm::codeview::yaml::YamlTypeDumperCallbacks::visitTypeBegin(
- CVType &CVR) {
- YamlIO.mapRequired("Kind", CVR.Type);
- return Error::success();
-}
-
-Error llvm::codeview::yaml::YamlTypeDumperCallbacks::visitMemberBegin(
- CVMemberRecord &Record) {
- YamlIO.mapRequired("Kind", Record.Kind);
- return Error::success();
-}
-
-void llvm::codeview::yaml::YamlTypeDumperCallbacks::visitKnownRecordImpl(
- const char *Name, CVType &CVR, FieldListRecord &FieldList) {
- std::vector<llvm::pdb::yaml::PdbTpiFieldListRecord> FieldListRecords;
- if (YamlIO.outputting()) {
- // 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).
- FieldListRecordSplitter Splitter(FieldListRecords);
- consumeError(codeview::visitMemberRecordStream(FieldList.Data, Splitter));
- }
- // Note that if we're not outputting (i.e. Yaml -> PDB) the result of this
- // mapping gets lost, as the records are simply stored in this locally scoped
- // vector. What's important though is they are all sharing a single
- // Serializer
- // instance (in `Context.ActiveSerializer`), and that is building up a list of
- // all the types. The fact that we need a throwaway vector here is just to
- // appease the YAML API to treat this as a sequence and do this mapping once
- // for each YAML Sequence element in the input Yaml stream.
- YamlIO.mapRequired("FieldList", FieldListRecords, Context);
-}
-
-namespace llvm {
-namespace yaml {
-template <>
-struct MappingContextTraits<pdb::yaml::PdbTpiFieldListRecord,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbTpiFieldListRecord &Obj,
- pdb::yaml::SerializationContext &Context) {
- if (IO.outputting())
- consumeError(codeview::visitMemberRecord(Obj.Record, Context.Dumper));
- else {
- // 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.
- assert(Context.ActiveSerializer && "There is no active serializer!");
- codeview::TypeVisitorCallbackPipeline Pipeline;
- pdb::TpiHashUpdater Hasher;
-
- Pipeline.addCallbackToPipeline(Context.Dumper);
- Pipeline.addCallbackToPipeline(*Context.ActiveSerializer);
- Pipeline.addCallbackToPipeline(Hasher);
- consumeError(
- codeview::visitMemberRecord(Obj.Record, Pipeline, VDS_BytesExternal));
- }
- }
-};
-}
-}
diff --git a/tools/llvm-pdbdump/YamlTypeDumper.h b/tools/llvm-pdbdump/YamlTypeDumper.h
deleted file mode 100644
index 3f15ba0bf85d..000000000000
--- a/tools/llvm-pdbdump/YamlTypeDumper.h
+++ /dev/null
@@ -1,116 +0,0 @@
-//===- YamlTypeDumper.h --------------------------------------- *- C++ --*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_YAMLTYPEDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_YAMLTYPEDUMPER_H
-
-#include "llvm/DebugInfo/CodeView/CodeView.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
-#include "llvm/Support/YAMLTraits.h"
-
-namespace llvm {
-namespace pdb {
-namespace yaml {
-struct SerializationContext;
-}
-}
-namespace codeview {
-namespace yaml {
-class YamlTypeDumperCallbacks : public TypeVisitorCallbacks {
-public:
- YamlTypeDumperCallbacks(llvm::yaml::IO &IO,
- llvm::pdb::yaml::SerializationContext &Context)
- : YamlIO(IO), Context(Context) {}
-
- virtual Error visitTypeBegin(CVType &Record) override;
- virtual Error visitMemberBegin(CVMemberRecord &Record) override;
-
-#define TYPE_RECORD(EnumName, EnumVal, Name) \
- Error visitKnownRecord(CVRecord<TypeLeafKind> &CVR, Name##Record &Record) \
- override { \
- visitKnownRecordImpl(#Name, CVR, Record); \
- return Error::success(); \
- }
-#define MEMBER_RECORD(EnumName, EnumVal, Name) \
- Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
- visitKnownMemberImpl(#Name, Record); \
- return Error::success(); \
- }
-#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#include "llvm/DebugInfo/CodeView/TypeRecords.def"
-
-private:
- template <typename T> void visitKnownMemberImpl(const char *Name, T &Record) {
- YamlIO.mapRequired(Name, Record);
- }
-
- template <typename T>
- void visitKnownRecordImpl(const char *Name, CVType &Type, T &Record) {
- YamlIO.mapRequired(Name, Record);
- }
-
- void visitKnownRecordImpl(const char *Name, CVType &CVR,
- FieldListRecord &FieldList);
-
- llvm::yaml::IO &YamlIO;
- llvm::pdb::yaml::SerializationContext &Context;
-};
-}
-}
-namespace pdb {
-namespace yaml {
-struct SerializationContext;
-}
-}
-}
-
-namespace llvm {
-namespace yaml {
-
-template <> struct ScalarTraits<APSInt> {
- static void output(const APSInt &S, void *, llvm::raw_ostream &OS);
- static StringRef input(StringRef Scalar, void *Ctx, APSInt &S);
- static bool mustQuote(StringRef Scalar);
-};
-
-template <> struct ScalarTraits<codeview::TypeIndex> {
- static void output(const codeview::TypeIndex &S, void *,
- llvm::raw_ostream &OS);
- static StringRef input(StringRef Scalar, void *Ctx, codeview::TypeIndex &S);
- static bool mustQuote(StringRef Scalar);
-};
-
-template <> struct MappingTraits<codeview::MemberPointerInfo> {
- static void mapping(IO &IO, codeview::MemberPointerInfo &Obj);
-};
-
-template <>
-struct MappingContextTraits<codeview::CVType, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, codeview::CVType &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct ScalarEnumerationTraits<codeview::TypeLeafKind> {
- static void enumeration(IO &io, codeview::TypeLeafKind &Value);
-};
-
-#define TYPE_RECORD(EnumName, EnumVal, Name) \
- template <> struct MappingTraits<codeview::Name##Record> { \
- static void mapping(IO &IO, codeview::Name##Record &Obj); \
- };
-#define MEMBER_RECORD(EnumName, EnumVal, Name) \
- TYPE_RECORD(EnumName, EnumVal, Name)
-#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#include "llvm/DebugInfo/CodeView/TypeRecords.def"
-}
-}
-
-#endif
diff --git a/tools/llvm-pdbdump/llvm-pdbdump.cpp b/tools/llvm-pdbdump/llvm-pdbdump.cpp
index baba862ae663..0b2b766a3c52 100644
--- a/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ b/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -476,6 +476,7 @@ static void yamlToPdb(StringRef Path) {
std::unique_ptr<MemoryBuffer> &Buffer = ErrorOrBuffer.get();
llvm::yaml::Input In(Buffer->getBuffer());
+ In.setContext(&Allocator);
pdb::yaml::PdbObject YamlObj(Allocator);
In >> YamlObj;
@@ -535,7 +536,7 @@ static void yamlToPdb(StringRef Path) {
if (MI.Modi.hasValue()) {
const auto &ModiStream = *MI.Modi;
for (auto Symbol : ModiStream.Symbols)
- ModiBuilder.addSymbol(Symbol.Record);
+ ModiBuilder.addSymbol(Symbol.toCodeViewSymbol(Allocator));
}
if (MI.FileLineInfo.hasValue()) {
const auto &FLI = *MI.FileLineInfo;
@@ -584,7 +585,7 @@ static void yamlToPdb(StringRef Path) {
auto Inlinees = llvm::make_unique<DebugInlineeLinesSubsection>(
ChecksumRef, Inlinee.HasExtraFiles);
for (const auto &Site : Inlinee.Sites) {
- Inlinees->addInlineSite(Site.Inlinee, Site.FileName,
+ Inlinees->addInlineSite(TypeIndex(Site.Inlinee), Site.FileName,
Site.SourceLineNum);
if (!Inlinee.HasExtraFiles)
continue;
@@ -601,14 +602,18 @@ static void yamlToPdb(StringRef Path) {
auto &TpiBuilder = Builder.getTpiBuilder();
const auto &Tpi = YamlObj.TpiStream.getValueOr(DefaultTpiStream);
TpiBuilder.setVersionHeader(Tpi.Version);
- for (const auto &R : Tpi.Records)
- TpiBuilder.addTypeRecord(R.Record.data(), R.Record.Hash);
+ for (const auto &R : Tpi.Records) {
+ CVType Type = R.toCodeViewRecord(Allocator);
+ TpiBuilder.addTypeRecord(Type.RecordData, None);
+ }
const auto &Ipi = YamlObj.IpiStream.getValueOr(DefaultIpiStream);
auto &IpiBuilder = Builder.getIpiBuilder();
IpiBuilder.setVersionHeader(Ipi.Version);
- for (const auto &R : Ipi.Records)
- IpiBuilder.addTypeRecord(R.Record.data(), R.Record.Hash);
+ for (const auto &R : Ipi.Records) {
+ CVType Type = R.toCodeViewRecord(Allocator);
+ IpiBuilder.addTypeRecord(Type.RecordData, None);
+ }
ExitOnErr(Builder.commit(opts::yaml2pdb::YamlPdbOutputFile));
}
diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp
index 2e9e01d9642b..427920569042 100644
--- a/tools/llvm-readobj/ELFDumper.cpp
+++ b/tools/llvm-readobj/ELFDumper.cpp
@@ -2742,6 +2742,7 @@ std::string GNUStyle<ELFT>::getSymbolSectionNdx(const ELFO *Obj,
case ELF::SHN_XINDEX:
SectionIndex = unwrapOrError(object::getExtendedSymbolTableIndex<ELFT>(
Symbol, FirstSym, this->dumper()->getShndxTable()));
+ LLVM_FALLTHROUGH;
default:
// Find if:
// Processor specific
diff --git a/tools/obj2yaml/macho2yaml.cpp b/tools/obj2yaml/macho2yaml.cpp
index 9ad2a6d979f5..f7b6c4748d5e 100644
--- a/tools/obj2yaml/macho2yaml.cpp
+++ b/tools/obj2yaml/macho2yaml.cpp
@@ -261,6 +261,7 @@ void MachODumper::dumpRebaseOpcodes(std::unique_ptr<MachOYAML::Object> &Y) {
ULEB = decodeULEB128(OpCode + 1, &Count);
RebaseOp.ExtraData.push_back(ULEB);
OpCode += Count;
+ LLVM_FALLTHROUGH;
// Intentionally no break here -- This opcode has two ULEB values
case MachO::REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB:
case MachO::REBASE_OPCODE_ADD_ADDR_ULEB:
@@ -308,6 +309,7 @@ void MachODumper::dumpBindOpcodes(
ULEB = decodeULEB128(OpCode + 1, &Count);
BindOp.ULEBExtraData.push_back(ULEB);
OpCode += Count;
+ LLVM_FALLTHROUGH;
// Intentionally no break here -- this opcode has two ULEB values
case MachO::BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB:
diff --git a/tools/opt/NewPMDriver.cpp b/tools/opt/NewPMDriver.cpp
index df467da690e7..58e9caeff0fb 100644
--- a/tools/opt/NewPMDriver.cpp
+++ b/tools/opt/NewPMDriver.cpp
@@ -29,6 +29,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
using namespace llvm;
@@ -47,8 +48,9 @@ static cl::opt<std::string>
"pipeline for handling managed aliasing queries"),
cl::Hidden);
-bool llvm::runPassPipeline(StringRef Arg0, Module &M,
- TargetMachine *TM, tool_output_file *Out,
+bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
+ tool_output_file *Out,
+ tool_output_file *ThinLTOLinkOut,
StringRef PassPipeline, OutputKind OK,
VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
@@ -104,6 +106,10 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M,
MPM.addPass(BitcodeWriterPass(Out->os(), ShouldPreserveBitcodeUseListOrder,
EmitSummaryIndex, EmitModuleHash));
break;
+ case OK_OutputThinLTOBitcode:
+ MPM.addPass(ThinLTOBitcodeWriterPass(
+ Out->os(), ThinLTOLinkOut ? &ThinLTOLinkOut->os() : nullptr));
+ break;
}
// Before executing passes, print the final values of the LLVM options.
@@ -113,7 +119,10 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M,
MPM.run(M, MAM);
// Declare success.
- if (OK != OK_NoOutput)
+ if (OK != OK_NoOutput) {
Out->keep();
+ if (OK == OK_OutputThinLTOBitcode && ThinLTOLinkOut)
+ ThinLTOLinkOut->keep();
+ }
return true;
}
diff --git a/tools/opt/NewPMDriver.h b/tools/opt/NewPMDriver.h
index 04022e7ec562..8012e0a025c9 100644
--- a/tools/opt/NewPMDriver.h
+++ b/tools/opt/NewPMDriver.h
@@ -32,7 +32,8 @@ namespace opt_tool {
enum OutputKind {
OK_NoOutput,
OK_OutputAssembly,
- OK_OutputBitcode
+ OK_OutputBitcode,
+ OK_OutputThinLTOBitcode,
};
enum VerifierKind {
VK_NoVerifier,
@@ -47,8 +48,11 @@ enum VerifierKind {
/// inclusion of the new pass manager headers and the old headers into the same
/// file. It's interface is consequentially somewhat ad-hoc, but will go away
/// when the transition finishes.
-bool runPassPipeline(StringRef Arg0, Module &M,
- TargetMachine *TM, tool_output_file *Out,
+///
+/// ThinLTOLinkOut is only used when OK is OK_OutputThinLTOBitcode, and can be
+/// nullptr.
+bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
+ tool_output_file *Out, tool_output_file *ThinLinkOut,
StringRef PassPipeline, opt_tool::OutputKind OK,
opt_tool::VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index bef197d603ca..9d489ab5a2d2 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -518,7 +518,9 @@ int main(int argc, char **argv) {
if (PassPipeline.getNumOccurrences() > 0) {
OutputKind OK = OK_NoOutput;
if (!NoOutput)
- OK = OutputAssembly ? OK_OutputAssembly : OK_OutputBitcode;
+ OK = OutputAssembly
+ ? OK_OutputAssembly
+ : (OutputThinLTOBC ? OK_OutputThinLTOBitcode : OK_OutputBitcode);
VerifierKind VK = VK_VerifyInAndOut;
if (NoVerify)
@@ -529,7 +531,7 @@ int main(int argc, char **argv) {
// The user has asked to use the new pass manager and provided a pipeline
// string. Hand off the rest of the functionality to the new code for that
// layer.
- return runPassPipeline(argv[0], *M, TM.get(), Out.get(),
+ return runPassPipeline(argv[0], *M, TM.get(), Out.get(), ThinLinkOut.get(),
PassPipeline, OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
EmitModuleHash)