]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r303571, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / CodeView / ModuleDebugInlineeLinesFragment.h
1 //===- ModuleDebugInlineeLinesFragment.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_DEBUGINFO_CODEVIEW_MODULEDEBUGINLINEELINESFRAGMENT_H
11 #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGINLINEELINESFRAGMENT_H
12
13 #include "llvm/DebugInfo/CodeView/Line.h"
14 #include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"
15 #include "llvm/Support/BinaryStreamArray.h"
16 #include "llvm/Support/BinaryStreamReader.h"
17 #include "llvm/Support/Error.h"
18
19 namespace llvm {
20 namespace codeview {
21
22 class ModuleDebugInlineeLineFragmentRef;
23 class ModuleDebugFileChecksumFragment;
24 class StringTable;
25
26 enum class InlineeLinesSignature : uint32_t {
27   Normal,    // CV_INLINEE_SOURCE_LINE_SIGNATURE
28   ExtraFiles // CV_INLINEE_SOURCE_LINE_SIGNATURE_EX
29 };
30
31 struct InlineeSourceLineHeader {
32   TypeIndex Inlinee;                  // ID of the function that was inlined.
33   support::ulittle32_t FileID;        // Offset into FileChecksums subsection.
34   support::ulittle32_t SourceLineNum; // First line of inlined code.
35                                       // If extra files present:
36                                       //   ulittle32_t ExtraFileCount;
37                                       //   ulittle32_t Files[];
38 };
39
40 struct InlineeSourceLine {
41   const InlineeSourceLineHeader *Header;
42   FixedStreamArray<support::ulittle32_t> ExtraFiles;
43 };
44 }
45
46 template <> struct VarStreamArrayExtractor<codeview::InlineeSourceLine> {
47   typedef bool ContextType;
48
49   static Error extract(BinaryStreamRef Stream, uint32_t &Len,
50                        codeview::InlineeSourceLine &Item, bool HasExtraFiles);
51 };
52
53 namespace codeview {
54 class ModuleDebugInlineeLineFragmentRef final : public ModuleDebugFragmentRef {
55   typedef VarStreamArray<InlineeSourceLine> LinesArray;
56   typedef LinesArray::Iterator Iterator;
57
58 public:
59   ModuleDebugInlineeLineFragmentRef();
60
61   static bool classof(const ModuleDebugFragmentRef *S) {
62     return S->kind() == ModuleDebugFragmentKind::InlineeLines;
63   }
64
65   Error initialize(BinaryStreamReader Reader);
66   bool hasExtraFiles() const;
67
68   Iterator begin() const { return Lines.begin(); }
69   Iterator end() const { return Lines.end(); }
70
71 private:
72   InlineeLinesSignature Signature;
73   VarStreamArray<InlineeSourceLine> Lines;
74 };
75
76 class ModuleDebugInlineeLineFragment final : public ModuleDebugFragment {
77 public:
78   ModuleDebugInlineeLineFragment(ModuleDebugFileChecksumFragment &Checksums,
79                                  bool HasExtraFiles);
80
81   static bool classof(const ModuleDebugFragment *S) {
82     return S->kind() == ModuleDebugFragmentKind::InlineeLines;
83   }
84
85   Error commit(BinaryStreamWriter &Writer) override;
86   uint32_t calculateSerializedLength() override;
87
88   void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine);
89   void addExtraFile(StringRef FileName);
90
91 private:
92   ModuleDebugFileChecksumFragment &Checksums;
93
94   bool HasExtraFiles = false;
95   uint32_t ExtraFileCount = 0;
96
97   struct Entry {
98     std::vector<support::ulittle32_t> ExtraFiles;
99     InlineeSourceLineHeader Header;
100   };
101   std::vector<Entry> Entries;
102 };
103 }
104 }
105
106 #endif