Zachary Turner | 3b14764 | 2016-10-08 01:12:01 +0000 | [diff] [blame] | 1 | //===- YamlSymbolDumper.h ------------------------------------- *- C++ --*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_TOOLS_LLVMPDBDUMP_YAMLSYMBOLDUMPER_H |
| 11 | #define LLVM_TOOLS_LLVMPDBDUMP_YAMLSYMBOLDUMPER_H |
| 12 | |
| 13 | #include "llvm/DebugInfo/CodeView/CodeView.h" |
| 14 | #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" |
| 15 | #include "llvm/Support/YAMLTraits.h" |
| 16 | |
| 17 | namespace llvm { |
| 18 | namespace pdb { |
| 19 | namespace yaml { |
| 20 | struct SerializationContext; |
| 21 | } |
| 22 | } |
| 23 | namespace codeview { |
| 24 | namespace yaml { |
| 25 | class YamlSymbolDumper : public SymbolVisitorCallbacks { |
| 26 | public: |
| 27 | YamlSymbolDumper(llvm::yaml::IO &IO) : YamlIO(IO) {} |
| 28 | |
| 29 | virtual Error visitSymbolBegin(CVSymbol &Record) override; |
| 30 | |
| 31 | #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ |
| 32 | Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ |
| 33 | visitKnownRecordImpl(#Name, CVR, Record); \ |
| 34 | return Error::success(); \ |
| 35 | } |
| 36 | #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) |
| 37 | #include "llvm/DebugInfo/CodeView/CVSymbolTypes.def" |
| 38 | |
| 39 | private: |
| 40 | template <typename T> |
| 41 | void visitKnownRecordImpl(const char *Name, CVSymbol &Type, T &Record) { |
| 42 | YamlIO.mapRequired(Name, Record); |
| 43 | } |
| 44 | |
| 45 | llvm::yaml::IO &YamlIO; |
| 46 | }; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | namespace llvm { |
| 52 | namespace yaml { |
| 53 | template <> struct ScalarEnumerationTraits<codeview::SymbolKind> { |
| 54 | static void enumeration(IO &io, codeview::SymbolKind &Value); |
| 55 | }; |
| 56 | |
| 57 | #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ |
| 58 | template <> struct MappingTraits<codeview::Name> { \ |
| 59 | static void mapping(IO &IO, codeview::Name &Obj); \ |
| 60 | }; |
| 61 | #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) |
| 62 | #include "llvm/DebugInfo/CodeView/CVSymbolTypes.def" |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | #endif |