]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
Merge ^/head r318560 through r318657.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / PDB / Native / DbiModuleDescriptorBuilder.h
1 //===- DbiModuleDescriptorBuilder.h - PDB module information ----*- 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_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
11 #define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
12
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
15 #include "llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h"
16 #include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"
17 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
18 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
19 #include "llvm/Support/Error.h"
20 #include <cstdint>
21 #include <string>
22 #include <vector>
23
24 namespace llvm {
25 class BinaryStreamWriter;
26
27 namespace codeview {
28 class ModuleDebugFragmentRecordBuilder;
29 }
30
31 namespace msf {
32 class MSFBuilder;
33 struct MSFLayout;
34 }
35 namespace pdb {
36
37 class DbiModuleDescriptorBuilder {
38   friend class DbiStreamBuilder;
39
40 public:
41   DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex,
42                              msf::MSFBuilder &Msf);
43   ~DbiModuleDescriptorBuilder();
44
45   DbiModuleDescriptorBuilder(const DbiModuleDescriptorBuilder &) = delete;
46   DbiModuleDescriptorBuilder &
47   operator=(const DbiModuleDescriptorBuilder &) = delete;
48
49   void setObjFileName(StringRef Name);
50   void addSymbol(codeview::CVSymbol Symbol);
51
52   void addC13Fragment(std::unique_ptr<codeview::ModuleDebugLineFragment> Lines);
53   void addC13Fragment(
54       std::unique_ptr<codeview::ModuleDebugInlineeLineFragment> Inlinees);
55   void setC13FileChecksums(
56       std::unique_ptr<codeview::ModuleDebugFileChecksumFragment> Checksums);
57
58   uint16_t getStreamIndex() const;
59   StringRef getModuleName() const { return ModuleName; }
60   StringRef getObjFileName() const { return ObjFileName; }
61
62   ArrayRef<std::string> source_files() const {
63     return makeArrayRef(SourceFiles);
64   }
65
66   uint32_t calculateSerializedLength() const;
67
68   void finalize();
69   Error finalizeMsfLayout();
70
71   Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout,
72                WritableBinaryStreamRef MsfBuffer);
73
74 private:
75   uint32_t calculateC13DebugInfoSize() const;
76
77   void addSourceFile(StringRef Path);
78   msf::MSFBuilder &MSF;
79
80   uint32_t SymbolByteSize = 0;
81   std::string ModuleName;
82   std::string ObjFileName;
83   std::vector<std::string> SourceFiles;
84   std::vector<codeview::CVSymbol> Symbols;
85
86   std::unique_ptr<codeview::ModuleDebugFileChecksumFragment> ChecksumInfo;
87   std::vector<std::unique_ptr<codeview::ModuleDebugLineFragment>> LineInfo;
88   std::vector<std::unique_ptr<codeview::ModuleDebugInlineeLineFragment>>
89       Inlinees;
90
91   std::vector<std::unique_ptr<codeview::ModuleDebugFragmentRecordBuilder>>
92       C13Builders;
93
94   ModuleInfoHeader Layout;
95 };
96
97 } // end namespace pdb
98
99 } // end namespace llvm
100
101 #endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H