]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r304659, and update
[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/DebugChecksumsSubsection.h"
15 #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
16 #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.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 DebugSubsectionRecordBuilder;
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
53   addDebugSubsection(std::unique_ptr<codeview::DebugSubsection> Subsection);
54
55   uint16_t getStreamIndex() const;
56   StringRef getModuleName() const { return ModuleName; }
57   StringRef getObjFileName() const { return ObjFileName; }
58
59   ArrayRef<std::string> source_files() const {
60     return makeArrayRef(SourceFiles);
61   }
62
63   uint32_t calculateSerializedLength() const;
64
65   void finalize();
66   Error finalizeMsfLayout();
67
68   Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout,
69                WritableBinaryStreamRef MsfBuffer);
70
71 private:
72   uint32_t calculateC13DebugInfoSize() const;
73
74   void addSourceFile(StringRef Path);
75   msf::MSFBuilder &MSF;
76
77   uint32_t SymbolByteSize = 0;
78   std::string ModuleName;
79   std::string ObjFileName;
80   std::vector<std::string> SourceFiles;
81   std::vector<codeview::CVSymbol> Symbols;
82
83   std::vector<std::unique_ptr<codeview::DebugSubsectionRecordBuilder>>
84       C13Builders;
85
86   ModuleInfoHeader Layout;
87 };
88
89 } // end namespace pdb
90
91 } // end namespace llvm
92
93 #endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H