blob: b2e5954c1f9a93047f8b53d9e71f870cb71d75a0 [file] [log] [blame]
Zachary Turner7120a472016-06-06 20:37:05 +00001//===- YAMLOutputStyle.cpp ------------------------------------ *- 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#include "YAMLOutputStyle.h"
11
Zachary Turner5b6e4e02017-04-29 01:13:21 +000012#include "C13DebugFragmentVisitor.h"
Zachary Turner7120a472016-06-06 20:37:05 +000013#include "PdbYaml.h"
14#include "llvm-pdbdump.h"
15
Zachary Turner8c099fe2017-05-30 16:36:15 +000016#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
17#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
18#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
19#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
20#include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
21#include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h"
Zachary Turneree3b9c22017-04-25 20:22:02 +000022#include "llvm/DebugInfo/CodeView/Line.h"
Zachary Turner3b147642016-10-08 01:12:01 +000023#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +000024#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
25#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
Zachary Turner67c56012017-04-27 16:11:19 +000026#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +000027#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
28#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
Zachary Turner5b6e4e02017-04-29 01:13:21 +000029#include "llvm/DebugInfo/PDB/Native/RawError.h"
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +000030#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
Zachary Turnerd4273832017-05-30 21:53:05 +000031#include "llvm/ObjectYAML/CodeViewYAML.h"
Zachary Turner7120a472016-06-06 20:37:05 +000032
33using namespace llvm;
Zachary Turnerc37cb0c2017-04-27 16:12:16 +000034using namespace llvm::codeview;
Zachary Turner7120a472016-06-06 20:37:05 +000035using namespace llvm::pdb;
36
Zachary Turnerc6d54da2016-09-09 17:46:17 +000037YAMLOutputStyle::YAMLOutputStyle(PDBFile &File)
Zachary Turnerea4e6072017-03-15 22:18:53 +000038 : File(File), Out(outs()), Obj(File.getAllocator()) {
39 Out.setWriteDefaultValues(!opts::pdb2yaml::Minimal);
40}
Zachary Turner7120a472016-06-06 20:37:05 +000041
Zachary Turnera30bd1a2016-06-30 17:42:48 +000042Error YAMLOutputStyle::dump() {
Bob Haarman69fd2b72017-05-26 23:46:20 +000043 if (opts::pdb2yaml::All) {
44 opts::pdb2yaml::StreamMetadata = true;
45 opts::pdb2yaml::StreamDirectory = true;
46 opts::pdb2yaml::PdbStream = true;
47 opts::pdb2yaml::StringTable = true;
48 opts::pdb2yaml::DbiStream = true;
49 opts::pdb2yaml::DbiModuleInfo = true;
50 opts::pdb2yaml::DbiModuleSyms = true;
51 opts::pdb2yaml::DbiModuleSourceFileInfo = true;
52 opts::pdb2yaml::DbiModuleSourceLineInfo = true;
53 opts::pdb2yaml::TpiStream = true;
54 opts::pdb2yaml::IpiStream = true;
55 }
56
Zachary Turnerfaa554b2016-07-15 22:16:56 +000057 if (opts::pdb2yaml::StreamDirectory)
Zachary Turner8848a7a2016-07-06 18:05:57 +000058 opts::pdb2yaml::StreamMetadata = true;
Zachary Turner3b147642016-10-08 01:12:01 +000059 if (opts::pdb2yaml::DbiModuleSyms)
60 opts::pdb2yaml::DbiModuleInfo = true;
Zachary Turneree3b9c22017-04-25 20:22:02 +000061
62 if (opts::pdb2yaml::DbiModuleSourceLineInfo)
63 opts::pdb2yaml::DbiModuleSourceFileInfo = true;
64
Zachary Turnerd218c262016-07-22 15:46:37 +000065 if (opts::pdb2yaml::DbiModuleSourceFileInfo)
66 opts::pdb2yaml::DbiModuleInfo = true;
Zachary Turneree3b9c22017-04-25 20:22:02 +000067
Zachary Turnerd218c262016-07-22 15:46:37 +000068 if (opts::pdb2yaml::DbiModuleInfo)
69 opts::pdb2yaml::DbiStream = true;
Zachary Turner8848a7a2016-07-06 18:05:57 +000070
Zachary Turner5b6e4e02017-04-29 01:13:21 +000071 // Some names from the module source file info get pulled from the string
72 // table, so if we're writing module source info, we have to write the string
73 // table as well.
74 if (opts::pdb2yaml::DbiModuleSourceLineInfo)
75 opts::pdb2yaml::StringTable = true;
76
Zachary Turnera30bd1a2016-06-30 17:42:48 +000077 if (auto EC = dumpFileHeaders())
78 return EC;
Zachary Turner7120a472016-06-06 20:37:05 +000079
Zachary Turnera30bd1a2016-06-30 17:42:48 +000080 if (auto EC = dumpStreamMetadata())
81 return EC;
82
83 if (auto EC = dumpStreamDirectory())
84 return EC;
85
Zachary Turner760ad4d2017-01-20 22:42:09 +000086 if (auto EC = dumpStringTable())
87 return EC;
88
Zachary Turner8848a7a2016-07-06 18:05:57 +000089 if (auto EC = dumpPDBStream())
90 return EC;
91
Zachary Turnerdbeaea72016-07-11 21:45:26 +000092 if (auto EC = dumpDbiStream())
93 return EC;
94
Zachary Turnerac5763e2016-08-18 16:49:29 +000095 if (auto EC = dumpTpiStream())
96 return EC;
97
Zachary Turnerde9ba152016-09-15 18:22:31 +000098 if (auto EC = dumpIpiStream())
99 return EC;
100
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000101 flush();
102 return Error::success();
103}
104
Zachary Turneree3b9c22017-04-25 20:22:02 +0000105namespace {
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000106class C13YamlVisitor : public C13DebugFragmentVisitor {
Zachary Turneree3b9c22017-04-25 20:22:02 +0000107public:
Zachary Turnerd4273832017-05-30 21:53:05 +0000108 C13YamlVisitor(CodeViewYAML::SourceFileInfo &Info, PDBFile &F)
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000109 : C13DebugFragmentVisitor(F), Info(Info) {}
Zachary Turneree3b9c22017-04-25 20:22:02 +0000110
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000111 Error handleFileChecksums() override {
112 for (const auto &C : *Checksums) {
Zachary Turnerd4273832017-05-30 21:53:05 +0000113 CodeViewYAML::SourceFileChecksumEntry Entry;
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000114 if (auto Result = getNameFromStringTable(C.FileNameOffset))
Zachary Turneree3b9c22017-04-25 20:22:02 +0000115 Entry.FileName = *Result;
116 else
117 return Result.takeError();
118
119 Entry.Kind = C.Kind;
120 Entry.ChecksumBytes.Bytes = C.Checksum;
121 Info.FileChecksums.push_back(Entry);
122 }
123 return Error::success();
124 }
125
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000126 Error handleLines() override {
127 for (const auto &LF : Lines) {
128 Info.LineFragments.emplace_back();
129 auto &Fragment = Info.LineFragments.back();
Zachary Turneree3b9c22017-04-25 20:22:02 +0000130
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000131 Fragment.CodeSize = LF.header()->CodeSize;
132 Fragment.Flags =
133 static_cast<codeview::LineFlags>(uint16_t(LF.header()->Flags));
134 Fragment.RelocOffset = LF.header()->RelocOffset;
135 Fragment.RelocSegment = LF.header()->RelocSegment;
Zachary Turneree3b9c22017-04-25 20:22:02 +0000136
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000137 for (const auto &L : LF) {
138 Fragment.Blocks.emplace_back();
139 auto &Block = Fragment.Blocks.back();
Zachary Turneree3b9c22017-04-25 20:22:02 +0000140
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000141 if (auto Result = getNameFromChecksumsBuffer(L.NameIndex))
142 Block.FileName = *Result;
143 else
144 return Result.takeError();
Zachary Turneree3b9c22017-04-25 20:22:02 +0000145
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000146 for (const auto &N : L.LineNumbers) {
Zachary Turnerd4273832017-05-30 21:53:05 +0000147 CodeViewYAML::SourceLineEntry Line;
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000148 Line.Offset = N.Offset;
149 codeview::LineInfo LI(N.Flags);
150 Line.LineStart = LI.getStartLine();
151 Line.EndDelta = LI.getLineDelta();
152 Line.IsStatement = LI.isStatement();
153 Block.Lines.push_back(Line);
154 }
Zachary Turneree3b9c22017-04-25 20:22:02 +0000155
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000156 if (LF.hasColumnInfo()) {
157 for (const auto &C : L.Columns) {
Zachary Turnerd4273832017-05-30 21:53:05 +0000158 CodeViewYAML::SourceColumnEntry Column;
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000159 Column.StartColumn = C.StartColumn;
160 Column.EndColumn = C.EndColumn;
161 Block.Columns.push_back(Column);
162 }
Zachary Turneree3b9c22017-04-25 20:22:02 +0000163 }
164 }
Zachary Turneree3b9c22017-04-25 20:22:02 +0000165 }
166 return Error::success();
167 }
168
Zachary Turneredef1452017-05-02 16:56:09 +0000169 Error handleInlineeLines() override {
170 for (const auto &ILF : InlineeLines) {
171 Info.Inlinees.emplace_back();
172 auto &Inlinee = Info.Inlinees.back();
173
174 Inlinee.HasExtraFiles = ILF.hasExtraFiles();
175 for (const auto &IL : ILF) {
176 Inlinee.Sites.emplace_back();
177 auto &Site = Inlinee.Sites.back();
178 if (auto Result = getNameFromChecksumsBuffer(IL.Header->FileID))
179 Site.FileName = *Result;
180 else
181 return Result.takeError();
182
Zachary Turnerd4273832017-05-30 21:53:05 +0000183 Site.Inlinee = IL.Header->Inlinee.getIndex();
Zachary Turneredef1452017-05-02 16:56:09 +0000184 Site.SourceLineNum = IL.Header->SourceLineNum;
185 if (ILF.hasExtraFiles()) {
186 for (const auto &EF : IL.ExtraFiles) {
187 if (auto Result = getNameFromChecksumsBuffer(EF))
188 Site.ExtraFiles.push_back(*Result);
189 else
190 return Result.takeError();
191 }
192 }
193 }
194 }
195 return Error::success();
196 }
197
Zachary Turneree3b9c22017-04-25 20:22:02 +0000198private:
Zachary Turnerd4273832017-05-30 21:53:05 +0000199 CodeViewYAML::SourceFileInfo &Info;
Zachary Turneree3b9c22017-04-25 20:22:02 +0000200};
201}
202
Zachary Turnerd4273832017-05-30 21:53:05 +0000203Expected<Optional<CodeViewYAML::SourceFileInfo>>
Zachary Turner7cc13e52017-05-01 16:46:39 +0000204YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS) {
Zachary Turneree3b9c22017-04-25 20:22:02 +0000205 if (!ModS.hasLineInfo())
206 return None;
207
Zachary Turnerd4273832017-05-30 21:53:05 +0000208 CodeViewYAML::SourceFileInfo Info;
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000209 C13YamlVisitor Visitor(Info, File);
Zachary Turner8c099fe2017-05-30 16:36:15 +0000210 if (auto EC =
211 codeview::visitDebugSubsections(ModS.linesAndChecksums(), Visitor))
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000212 return std::move(EC);
Zachary Turneree3b9c22017-04-25 20:22:02 +0000213
214 return Info;
215}
216
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000217Error YAMLOutputStyle::dumpFileHeaders() {
Zachary Turnerf6b93822016-07-11 21:45:09 +0000218 if (opts::pdb2yaml::NoFileHeaders)
219 return Error::success();
220
Zachary Turnera3225b02016-07-29 20:56:36 +0000221 yaml::MSFHeaders Headers;
Zachary Turnerf6b93822016-07-11 21:45:09 +0000222 Obj.Headers.emplace();
223 Obj.Headers->SuperBlock.NumBlocks = File.getBlockCount();
224 Obj.Headers->SuperBlock.BlockMapAddr = File.getBlockMapIndex();
Zachary Turnerf6b93822016-07-11 21:45:09 +0000225 Obj.Headers->SuperBlock.BlockSize = File.getBlockSize();
Zachary Turner7120a472016-06-06 20:37:05 +0000226 auto Blocks = File.getDirectoryBlockArray();
Zachary Turnerf6b93822016-07-11 21:45:09 +0000227 Obj.Headers->DirectoryBlocks.assign(Blocks.begin(), Blocks.end());
228 Obj.Headers->NumDirectoryBlocks = File.getNumDirectoryBlocks();
229 Obj.Headers->SuperBlock.NumDirectoryBytes = File.getNumDirectoryBytes();
230 Obj.Headers->NumStreams =
Zachary Turnerab58ae82016-06-30 17:43:00 +0000231 opts::pdb2yaml::StreamMetadata ? File.getNumStreams() : 0;
Zachary Turnerb927e022016-07-15 22:17:19 +0000232 Obj.Headers->SuperBlock.FreeBlockMapBlock = File.getFreeBlockMapBlock();
Zachary Turnerf6b93822016-07-11 21:45:09 +0000233 Obj.Headers->SuperBlock.Unknown1 = File.getUnknown1();
234 Obj.Headers->FileSize = File.getFileSize();
Zachary Turner7120a472016-06-06 20:37:05 +0000235
236 return Error::success();
237}
238
Zachary Turner760ad4d2017-01-20 22:42:09 +0000239Error YAMLOutputStyle::dumpStringTable() {
240 if (!opts::pdb2yaml::StringTable)
241 return Error::success();
242
243 Obj.StringTable.emplace();
244 auto ExpectedST = File.getStringTable();
245 if (!ExpectedST)
246 return ExpectedST.takeError();
247
248 const auto &ST = ExpectedST.get();
249 for (auto ID : ST.name_ids()) {
Zachary Turner2d5c2cd2017-05-03 17:11:11 +0000250 auto S = ST.getStringForID(ID);
251 if (!S)
252 return S.takeError();
253 if (S->empty())
254 continue;
255 Obj.StringTable->push_back(*S);
Zachary Turner760ad4d2017-01-20 22:42:09 +0000256 }
257 return Error::success();
258}
259
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000260Error YAMLOutputStyle::dumpStreamMetadata() {
261 if (!opts::pdb2yaml::StreamMetadata)
Zachary Turner7120a472016-06-06 20:37:05 +0000262 return Error::success();
263
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000264 Obj.StreamSizes.emplace();
265 Obj.StreamSizes->assign(File.getStreamSizes().begin(),
266 File.getStreamSizes().end());
Zachary Turner7120a472016-06-06 20:37:05 +0000267 return Error::success();
268}
269
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000270Error YAMLOutputStyle::dumpStreamDirectory() {
271 if (!opts::pdb2yaml::StreamDirectory)
Zachary Turner7120a472016-06-06 20:37:05 +0000272 return Error::success();
273
Zachary Turner1dc9fd32016-06-14 20:48:36 +0000274 auto StreamMap = File.getStreamMap();
275 Obj.StreamMap.emplace();
276 for (auto &Stream : StreamMap) {
277 pdb::yaml::StreamBlockList BlockList;
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000278 BlockList.Blocks.assign(Stream.begin(), Stream.end());
Zachary Turner1dc9fd32016-06-14 20:48:36 +0000279 Obj.StreamMap->push_back(BlockList);
Zachary Turner25e8b052016-06-06 20:37:17 +0000280 }
Zachary Turner25e8b052016-06-06 20:37:17 +0000281
Zachary Turner7120a472016-06-06 20:37:05 +0000282 return Error::success();
283}
284
Zachary Turner8848a7a2016-07-06 18:05:57 +0000285Error YAMLOutputStyle::dumpPDBStream() {
286 if (!opts::pdb2yaml::PdbStream)
287 return Error::success();
288
289 auto IS = File.getPDBInfoStream();
290 if (!IS)
291 return IS.takeError();
292
293 auto &InfoS = IS.get();
294 Obj.PdbStream.emplace();
295 Obj.PdbStream->Age = InfoS.getAge();
296 Obj.PdbStream->Guid = InfoS.getGuid();
297 Obj.PdbStream->Signature = InfoS.getSignature();
298 Obj.PdbStream->Version = InfoS.getVersion();
Zachary Turner05d5e612017-03-16 20:19:11 +0000299 Obj.PdbStream->Features = InfoS.getFeatureSignatures();
Zachary Turner8848a7a2016-07-06 18:05:57 +0000300
301 return Error::success();
302}
303
Zachary Turnerdbeaea72016-07-11 21:45:26 +0000304Error YAMLOutputStyle::dumpDbiStream() {
305 if (!opts::pdb2yaml::DbiStream)
306 return Error::success();
307
308 auto DbiS = File.getPDBDbiStream();
309 if (!DbiS)
310 return DbiS.takeError();
311
312 auto &DS = DbiS.get();
313 Obj.DbiStream.emplace();
314 Obj.DbiStream->Age = DS.getAge();
315 Obj.DbiStream->BuildNumber = DS.getBuildNumber();
316 Obj.DbiStream->Flags = DS.getFlags();
317 Obj.DbiStream->MachineType = DS.getMachineType();
318 Obj.DbiStream->PdbDllRbld = DS.getPdbDllRbld();
319 Obj.DbiStream->PdbDllVersion = DS.getPdbDllVersion();
320 Obj.DbiStream->VerHeader = DS.getDbiVersion();
Zachary Turnerd218c262016-07-22 15:46:37 +0000321 if (opts::pdb2yaml::DbiModuleInfo) {
Zachary Turner1eb9a022017-05-04 23:53:29 +0000322 const auto &Modules = DS.modules();
323 for (uint32_t I = 0; I < Modules.getModuleCount(); ++I) {
324 DbiModuleDescriptor MI = Modules.getModuleDescriptor(I);
325
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000326 Obj.DbiStream->ModInfos.emplace_back();
327 yaml::PdbDbiModuleInfo &DMI = Obj.DbiStream->ModInfos.back();
328
Zachary Turner1eb9a022017-05-04 23:53:29 +0000329 DMI.Mod = MI.getModuleName();
330 DMI.Obj = MI.getObjFileName();
331 if (opts::pdb2yaml::DbiModuleSourceFileInfo) {
332 auto Files = Modules.source_files(I);
333 DMI.SourceFiles.assign(Files.begin(), Files.end());
334 }
Zachary Turner3b147642016-10-08 01:12:01 +0000335
Zachary Turner1eb9a022017-05-04 23:53:29 +0000336 uint16_t ModiStream = MI.getModuleStreamIndex();
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000337 if (ModiStream == kInvalidStreamIndex)
338 continue;
339
Zachary Turneree3b9c22017-04-25 20:22:02 +0000340 auto ModStreamData = msf::MappedBlockStream::createIndexedStream(
Zachary Turner8a2ebfb2017-05-01 23:27:42 +0000341 File.getMsfLayout(), File.getMsfBuffer(), ModiStream);
Zachary Turneree3b9c22017-04-25 20:22:02 +0000342
Zachary Turner1eb9a022017-05-04 23:53:29 +0000343 pdb::ModuleDebugStreamRef ModS(MI, std::move(ModStreamData));
Zachary Turneree3b9c22017-04-25 20:22:02 +0000344 if (auto EC = ModS.reload())
345 return EC;
346
347 if (opts::pdb2yaml::DbiModuleSourceLineInfo) {
348 auto ExpectedInfo = getFileLineInfo(ModS);
349 if (!ExpectedInfo)
350 return ExpectedInfo.takeError();
351 DMI.FileLineInfo = *ExpectedInfo;
352 }
353
Zachary Turner5b6e4e02017-04-29 01:13:21 +0000354 if (opts::pdb2yaml::DbiModuleSyms) {
Zachary Turner3b147642016-10-08 01:12:01 +0000355 DMI.Modi.emplace();
Zachary Turner3b147642016-10-08 01:12:01 +0000356
357 DMI.Modi->Signature = ModS.signature();
358 bool HadError = false;
359 for (auto &Sym : ModS.symbols(&HadError)) {
Zachary Turner1e4d3692017-05-30 23:50:44 +0000360 auto ES = CodeViewYAML::SymbolRecord::fromCodeViewSymbol(Sym);
361 if (!ES)
362 return ES.takeError();
363
364 DMI.Modi->Symbols.push_back(*ES);
Zachary Turner3b147642016-10-08 01:12:01 +0000365 }
366 }
Zachary Turnerd218c262016-07-22 15:46:37 +0000367 }
368 }
Zachary Turnerdbeaea72016-07-11 21:45:26 +0000369 return Error::success();
370}
371
Zachary Turnerac5763e2016-08-18 16:49:29 +0000372Error YAMLOutputStyle::dumpTpiStream() {
373 if (!opts::pdb2yaml::TpiStream)
374 return Error::success();
375
376 auto TpiS = File.getPDBTpiStream();
377 if (!TpiS)
378 return TpiS.takeError();
379
380 auto &TS = TpiS.get();
381 Obj.TpiStream.emplace();
382 Obj.TpiStream->Version = TS.getTpiVersion();
383 for (auto &Record : TS.types(nullptr)) {
Zachary Turnerd4273832017-05-30 21:53:05 +0000384 auto ExpectedRecord = CodeViewYAML::LeafRecord::fromCodeViewRecord(Record);
385 if (!ExpectedRecord)
386 return ExpectedRecord.takeError();
387 Obj.TpiStream->Records.push_back(*ExpectedRecord);
Zachary Turnerac5763e2016-08-18 16:49:29 +0000388 }
389
390 return Error::success();
391}
392
Zachary Turnerde9ba152016-09-15 18:22:31 +0000393Error YAMLOutputStyle::dumpIpiStream() {
394 if (!opts::pdb2yaml::IpiStream)
395 return Error::success();
396
397 auto IpiS = File.getPDBIpiStream();
398 if (!IpiS)
399 return IpiS.takeError();
400
401 auto &IS = IpiS.get();
402 Obj.IpiStream.emplace();
403 Obj.IpiStream->Version = IS.getTpiVersion();
404 for (auto &Record : IS.types(nullptr)) {
Zachary Turnerd4273832017-05-30 21:53:05 +0000405 auto ExpectedRecord = CodeViewYAML::LeafRecord::fromCodeViewRecord(Record);
406 if (!ExpectedRecord)
407 return ExpectedRecord.takeError();
408
409 Obj.IpiStream->Records.push_back(*ExpectedRecord);
Zachary Turnerde9ba152016-09-15 18:22:31 +0000410 }
411
412 return Error::success();
413}
414
Zachary Turner7120a472016-06-06 20:37:05 +0000415void YAMLOutputStyle::flush() {
416 Out << Obj;
417 outs().flush();
418}