xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/PDBExtras.cpp (revision d56accc7c3dcc897489b6a07834763a03b9f3d68)
1 //===- PDBExtras.cpp - helper functions and classes for PDBs --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/DebugInfo/PDB/PDBExtras.h"
10 #include "llvm/ADT/ArrayRef.h"
11 #include "llvm/Support/raw_ostream.h"
12 
13 using namespace llvm;
14 using namespace llvm::pdb;
15 
16 #define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream)                  \
17   case Class::Value:                                                           \
18     Stream << Str;                                                             \
19     break;
20 
21 #define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream)                      \
22   CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, #Value, Stream)
23 
24 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
25                                    const PDB_VariantType &Type) {
26   switch (Type) {
27     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Bool, OS)
28     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Single, OS)
29     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Double, OS)
30     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int8, OS)
31     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int16, OS)
32     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int32, OS)
33     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int64, OS)
34     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt8, OS)
35     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt16, OS)
36     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt32, OS)
37     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt64, OS)
38     default:
39       OS << "Unknown";
40   }
41   return OS;
42 }
43 
44 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
45                                    const PDB_BuiltinType &Type) {
46   switch (Type) {
47     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, None, OS)
48     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Void, OS)
49     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char, OS)
50     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, WCharT, OS)
51     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Int, OS)
52     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, UInt, OS)
53     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Float, OS)
54     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, BCD, OS)
55     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Bool, OS)
56     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Long, OS)
57     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, ULong, OS)
58     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Currency, OS)
59     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Date, OS)
60     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Variant, OS)
61     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Complex, OS)
62     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Bitfield, OS)
63     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, BSTR, OS)
64     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, HResult, OS)
65     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char16, OS)
66     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char32, OS)
67   }
68   return OS;
69 }
70 
71 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
72                                    const PDB_CallingConv &Conv) {
73   OS << "__";
74   switch (Conv) {
75     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearC      , "cdecl", OS)
76     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarC       , "cdecl", OS)
77     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearPascal , "pascal", OS)
78     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarPascal  , "pascal", OS)
79     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearFast   , "fastcall", OS)
80     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarFast    , "fastcall", OS)
81     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearStdCall, "stdcall", OS)
82     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarStdCall , "stdcall", OS)
83     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearSysCall, "syscall", OS)
84     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarSysCall , "syscall", OS)
85     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ThisCall   , "thiscall", OS)
86     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, MipsCall   , "mipscall", OS)
87     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Generic    , "genericcall", OS)
88     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AlphaCall  , "alphacall", OS)
89     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, PpcCall    , "ppccall", OS)
90     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SHCall     , "superhcall", OS)
91     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ArmCall    , "armcall", OS)
92     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AM33Call   , "am33call", OS)
93     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, TriCall    , "tricall", OS)
94     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SH5Call    , "sh5call", OS)
95     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, M32RCall   , "m32rcall", OS)
96     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ClrCall    , "clrcall", OS)
97     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline     , "inlinecall", OS)
98     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVector , "vectorcall", OS)
99   }
100   return OS;
101 }
102 
103 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_DataKind &Data) {
104   switch (Data) {
105     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Unknown, "unknown", OS)
106     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Local, "local", OS)
107     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, StaticLocal, "static local", OS)
108     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Param, "param", OS)
109     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, ObjectPtr, "this ptr", OS)
110     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, FileStatic, "static global", OS)
111     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Global, "global", OS)
112     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Member, "member", OS)
113     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, StaticMember, "static member", OS)
114     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Constant, "const", OS)
115   }
116   return OS;
117 }
118 
119 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
120                                    const llvm::codeview::CPURegister &CpuReg) {
121   if (CpuReg.Cpu == llvm::codeview::CPUType::ARMNT) {
122     switch (CpuReg.Reg) {
123 #define CV_REGISTERS_ARM
124 #define CV_REGISTER(name, val)                                                 \
125   case codeview::RegisterId::name:                                             \
126     OS << #name;                                                               \
127     return OS;
128 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
129 #undef CV_REGISTER
130 #undef CV_REGISTERS_ARM
131 
132     default:
133       break;
134     }
135   } else if (CpuReg.Cpu == llvm::codeview::CPUType::ARM64) {
136     switch (CpuReg.Reg) {
137 #define CV_REGISTERS_ARM64
138 #define CV_REGISTER(name, val)                                                 \
139   case codeview::RegisterId::name:                                             \
140     OS << #name;                                                               \
141     return OS;
142 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
143 #undef CV_REGISTER
144 #undef CV_REGISTERS_ARM64
145 
146     default:
147       break;
148     }
149   } else {
150     switch (CpuReg.Reg) {
151 #define CV_REGISTERS_X86
152 #define CV_REGISTER(name, val)                                                 \
153   case codeview::RegisterId::name:                                             \
154     OS << #name;                                                               \
155     return OS;
156 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
157 #undef CV_REGISTER
158 #undef CV_REGISTERS_X86
159 
160     default:
161       break;
162     }
163   }
164   OS << static_cast<int>(CpuReg.Reg);
165   return OS;
166 }
167 
168 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_LocType &Loc) {
169   switch (Loc) {
170     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Static, "static", OS)
171     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, TLS, "tls", OS)
172     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, RegRel, "regrel", OS)
173     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, ThisRel, "thisrel", OS)
174     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Enregistered, "register", OS)
175     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, BitField, "bitfield", OS)
176     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Slot, "slot", OS)
177     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, IlRel, "IL rel", OS)
178     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, MetaData, "metadata", OS)
179     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Constant, "constant", OS)
180     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, RegRelAliasIndir,
181                                "regrelaliasindir", OS)
182   default:
183     OS << "Unknown";
184   }
185   return OS;
186 }
187 
188 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
189                                    const codeview::ThunkOrdinal &Thunk) {
190   switch (Thunk) {
191     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, BranchIsland, OS)
192     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, Pcode, OS)
193     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, Standard, OS)
194     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, ThisAdjustor, OS)
195     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, TrampIncremental, OS)
196     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, UnknownLoad, OS)
197     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, Vcall, OS)
198   }
199   return OS;
200 }
201 
202 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
203                                    const PDB_Checksum &Checksum) {
204   switch (Checksum) {
205     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, None, OS)
206     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, MD5, OS)
207     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, SHA1, OS)
208     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, SHA256, OS)
209   }
210   return OS;
211 }
212 
213 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_Lang &Lang) {
214   switch (Lang) {
215     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, C, OS)
216     CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, Cpp, "C++", OS)
217     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Fortran, OS)
218     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Masm, OS)
219     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Pascal, OS)
220     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Basic, OS)
221     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cobol, OS)
222     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Link, OS)
223     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cvtres, OS)
224     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cvtpgd, OS)
225     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, CSharp, OS)
226     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, VB, OS)
227     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, ILAsm, OS)
228     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Java, OS)
229     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, JScript, OS)
230     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, MSIL, OS)
231     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, HLSL, OS)
232     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, D, OS)
233     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Swift, OS)
234     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Rust, OS)
235   }
236   return OS;
237 }
238 
239 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_SymType &Tag) {
240   switch (Tag) {
241     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Exe, OS)
242     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Compiland, OS)
243     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CompilandDetails, OS)
244     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CompilandEnv, OS)
245     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Function, OS)
246     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Block, OS)
247     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Data, OS)
248     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Annotation, OS)
249     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Label, OS)
250     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, PublicSymbol, OS)
251     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, UDT, OS)
252     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Enum, OS)
253     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FunctionSig, OS)
254     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, PointerType, OS)
255     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, ArrayType, OS)
256     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BuiltinType, OS)
257     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Typedef, OS)
258     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BaseClass, OS)
259     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Friend, OS)
260     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FunctionArg, OS)
261     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FuncDebugStart, OS)
262     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FuncDebugEnd, OS)
263     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, UsingNamespace, OS)
264     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VTableShape, OS)
265     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VTable, OS)
266     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Custom, OS)
267     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Thunk, OS)
268     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CustomType, OS)
269     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, ManagedType, OS)
270     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Dimension, OS)
271     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CallSite, OS)
272     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, InlineSite, OS)
273     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BaseInterface, OS)
274     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VectorType, OS)
275     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, MatrixType, OS)
276     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, HLSLType, OS)
277     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Caller, OS)
278     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Callee, OS)
279     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Export, OS)
280     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, HeapAllocationSite, OS)
281     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CoffGroup, OS)
282     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Inlinee, OS)
283   default:
284     OS << "Unknown SymTag " << uint32_t(Tag);
285   }
286   return OS;
287 }
288 
289 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
290                                    const PDB_MemberAccess &Access) {
291   switch (Access) {
292     CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Public, "public", OS)
293     CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Protected, "protected", OS)
294     CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Private, "private", OS)
295   }
296   return OS;
297 }
298 
299 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_UdtType &Type) {
300   switch (Type) {
301     CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
302     CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Struct, "struct", OS)
303     CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Interface, "interface", OS)
304     CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Union, "union", OS)
305   }
306   return OS;
307 }
308 
309 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
310                                    const PDB_Machine &Machine) {
311   switch (Machine) {
312     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Am33, OS)
313     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Amd64, OS)
314     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Arm, OS)
315     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, ArmNT, OS)
316     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Ebc, OS)
317     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, x86, OS)
318     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Ia64, OS)
319     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, M32R, OS)
320     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Mips16, OS)
321     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, MipsFpu, OS)
322     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, MipsFpu16, OS)
323     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, PowerPC, OS)
324     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, PowerPCFP, OS)
325     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, R4000, OS)
326     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH3, OS)
327     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH3DSP, OS)
328     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH4, OS)
329     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH5, OS)
330     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Thumb, OS)
331     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, WceMipsV2, OS)
332   default:
333     OS << "Unknown";
334   }
335   return OS;
336 }
337 
338 raw_ostream &llvm::pdb::dumpPDBSourceCompression(raw_ostream &OS,
339                                                  uint32_t Compression) {
340   switch (Compression) {
341     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, None, OS)
342     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, Huffman, OS)
343     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, LZ, OS)
344     CASE_OUTPUT_ENUM_CLASS_STR(PDB_SourceCompression, RunLengthEncoded, "RLE",
345                                OS)
346     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, DotNet, OS)
347   default:
348     OS << "Unknown (" << Compression << ")";
349   }
350   return OS;
351 }
352 
353 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const Variant &Value) {
354   switch (Value.Type) {
355     case PDB_VariantType::Bool:
356       OS << (Value.Value.Bool ? "true" : "false");
357       break;
358     case PDB_VariantType::Double:
359       OS << Value.Value.Double;
360       break;
361     case PDB_VariantType::Int16:
362       OS << Value.Value.Int16;
363       break;
364     case PDB_VariantType::Int32:
365       OS << Value.Value.Int32;
366       break;
367     case PDB_VariantType::Int64:
368       OS << Value.Value.Int64;
369       break;
370     case PDB_VariantType::Int8:
371       OS << static_cast<int>(Value.Value.Int8);
372       break;
373     case PDB_VariantType::Single:
374       OS << Value.Value.Single;
375       break;
376     case PDB_VariantType::UInt16:
377       OS << Value.Value.UInt16;
378       break;
379     case PDB_VariantType::UInt32:
380       OS << Value.Value.UInt32;
381       break;
382     case PDB_VariantType::UInt64:
383       OS << Value.Value.UInt64;
384       break;
385     case PDB_VariantType::UInt8:
386       OS << static_cast<unsigned>(Value.Value.UInt8);
387       break;
388     case PDB_VariantType::String:
389       OS << Value.Value.String;
390       break;
391     default:
392       OS << Value.Type;
393   }
394   return OS;
395 }
396 
397 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
398                                    const VersionInfo &Version) {
399   OS << Version.Major << "." << Version.Minor << "." << Version.Build;
400   return OS;
401 }
402 
403 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const TagStats &Stats) {
404   for (auto Tag : Stats) {
405     OS << Tag.first << ":" << Tag.second << " ";
406   }
407   return OS;
408 }
409