LLVM 22.0.0git
StringsAndChecksums.h
Go to the documentation of this file.
1//===- StringsAndChecksums.h ------------------------------------*- C++ -*-===//
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#ifndef LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H
10#define LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H
11
15#include <memory>
16
17namespace llvm {
18namespace codeview {
19class DebugChecksumsSubsection;
20class DebugChecksumsSubsectionRef;
21class DebugStringTableSubsection;
22class DebugStringTableSubsectionRef;
23
25public:
26 // If no subsections are known about initially, we find as much as we can.
28
29 // If only a string table subsection is given, we find a checksums subsection.
31 const DebugStringTableSubsectionRef &Strings);
32
33 // If both subsections are given, we don't need to find anything.
35 const DebugChecksumsSubsectionRef &Checksums);
36
39
40 LLVM_ABI void reset();
43
44 template <typename T> void initialize(T &&FragmentRange) {
45 for (const DebugSubsectionRecord &R : FragmentRange) {
46 if (Strings && Checksums)
47 return;
48 if (R.kind() == DebugSubsectionKind::FileChecksums) {
49 initializeChecksums(R);
50 continue;
51 }
52 if (R.kind() == DebugSubsectionKind::StringTable && !Strings) {
53 // While in practice we should never encounter a string table even
54 // though the string table is already initialized, in theory it's
55 // possible. PDBs are supposed to have one global string table and
56 // then this subsection should not appear. Whereas object files are
57 // supposed to have this subsection appear exactly once. However,
58 // for testing purposes it's nice to be able to test this subsection
59 // independently of one format or the other, so for some tests we
60 // manually construct a PDB that contains this subsection in addition
61 // to a global string table.
62 initializeStrings(R);
63 continue;
64 }
65 }
66 }
67
68 const DebugStringTableSubsectionRef &strings() const { return *Strings; }
69 const DebugChecksumsSubsectionRef &checksums() const { return *Checksums; }
70
71 bool hasStrings() const { return Strings != nullptr; }
72 bool hasChecksums() const { return Checksums != nullptr; }
73
74private:
75 LLVM_ABI void initializeStrings(const DebugSubsectionRecord &SR);
76 LLVM_ABI void initializeChecksums(const DebugSubsectionRecord &FCR);
77
78 std::shared_ptr<DebugStringTableSubsectionRef> OwnedStrings;
79 std::shared_ptr<DebugChecksumsSubsectionRef> OwnedChecksums;
80
81 const DebugStringTableSubsectionRef *Strings = nullptr;
82 const DebugChecksumsSubsectionRef *Checksums = nullptr;
83};
84
86public:
87 using StringsPtr = std::shared_ptr<DebugStringTableSubsection>;
88 using ChecksumsPtr = std::shared_ptr<DebugChecksumsSubsection>;
89
90 // If no subsections are known about initially, we find as much as we can.
92
93 void setStrings(const StringsPtr &SP) { Strings = SP; }
94 void setChecksums(const ChecksumsPtr &CP) { Checksums = CP; }
95
96 const StringsPtr &strings() const { return Strings; }
97 const ChecksumsPtr &checksums() const { return Checksums; }
98
99 bool hasStrings() const { return Strings != nullptr; }
100 bool hasChecksums() const { return Checksums != nullptr; }
101
102private:
103 StringsPtr Strings;
104 ChecksumsPtr Checksums;
105};
106
107} // end namespace codeview
108} // end namespace llvm
109
110#endif // LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H
#define LLVM_ABI
Definition: Compiler.h:213
Represents a read-only view of a CodeView string table.
LLVM_ABI void setStrings(const DebugStringTableSubsectionRef &Strings)
LLVM_ABI void setChecksums(const DebugChecksumsSubsectionRef &CS)
const DebugStringTableSubsectionRef & strings() const
const DebugChecksumsSubsectionRef & checksums() const
std::shared_ptr< DebugStringTableSubsection > StringsPtr
void setStrings(const StringsPtr &SP)
std::shared_ptr< DebugChecksumsSubsection > ChecksumsPtr
const StringsPtr & strings() const
void setChecksums(const ChecksumsPtr &CP)
const ChecksumsPtr & checksums() const
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18