File indexing completed on 2026-05-10 08:43:40
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H
0011
0012 #include "llvm/DebugInfo/CodeView/CodeView.h"
0013 #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
0014 #include <memory>
0015
0016 namespace llvm {
0017 namespace codeview {
0018 class DebugChecksumsSubsection;
0019 class DebugChecksumsSubsectionRef;
0020 class DebugStringTableSubsection;
0021 class DebugStringTableSubsectionRef;
0022
0023 class StringsAndChecksumsRef {
0024 public:
0025
0026 StringsAndChecksumsRef();
0027
0028
0029 explicit StringsAndChecksumsRef(const DebugStringTableSubsectionRef &Strings);
0030
0031
0032 StringsAndChecksumsRef(const DebugStringTableSubsectionRef &Strings,
0033 const DebugChecksumsSubsectionRef &Checksums);
0034
0035 void setStrings(const DebugStringTableSubsectionRef &Strings);
0036 void setChecksums(const DebugChecksumsSubsectionRef &CS);
0037
0038 void reset();
0039 void resetStrings();
0040 void resetChecksums();
0041
0042 template <typename T> void initialize(T &&FragmentRange) {
0043 for (const DebugSubsectionRecord &R : FragmentRange) {
0044 if (Strings && Checksums)
0045 return;
0046 if (R.kind() == DebugSubsectionKind::FileChecksums) {
0047 initializeChecksums(R);
0048 continue;
0049 }
0050 if (R.kind() == DebugSubsectionKind::StringTable && !Strings) {
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 initializeStrings(R);
0061 continue;
0062 }
0063 }
0064 }
0065
0066 const DebugStringTableSubsectionRef &strings() const { return *Strings; }
0067 const DebugChecksumsSubsectionRef &checksums() const { return *Checksums; }
0068
0069 bool hasStrings() const { return Strings != nullptr; }
0070 bool hasChecksums() const { return Checksums != nullptr; }
0071
0072 private:
0073 void initializeStrings(const DebugSubsectionRecord &SR);
0074 void initializeChecksums(const DebugSubsectionRecord &FCR);
0075
0076 std::shared_ptr<DebugStringTableSubsectionRef> OwnedStrings;
0077 std::shared_ptr<DebugChecksumsSubsectionRef> OwnedChecksums;
0078
0079 const DebugStringTableSubsectionRef *Strings = nullptr;
0080 const DebugChecksumsSubsectionRef *Checksums = nullptr;
0081 };
0082
0083 class StringsAndChecksums {
0084 public:
0085 using StringsPtr = std::shared_ptr<DebugStringTableSubsection>;
0086 using ChecksumsPtr = std::shared_ptr<DebugChecksumsSubsection>;
0087
0088
0089 StringsAndChecksums() = default;
0090
0091 void setStrings(const StringsPtr &SP) { Strings = SP; }
0092 void setChecksums(const ChecksumsPtr &CP) { Checksums = CP; }
0093
0094 const StringsPtr &strings() const { return Strings; }
0095 const ChecksumsPtr &checksums() const { return Checksums; }
0096
0097 bool hasStrings() const { return Strings != nullptr; }
0098 bool hasChecksums() const { return Checksums != nullptr; }
0099
0100 private:
0101 StringsPtr Strings;
0102 ChecksumsPtr Checksums;
0103 };
0104
0105 }
0106 }
0107
0108 #endif