LLVM 22.0.0git
DebugChecksumsSubsection.h
Go to the documentation of this file.
1//===- DebugChecksumsSubsection.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_DEBUGCHECKSUMSSUBSECTION_H
10#define LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/StringRef.h"
21#include "llvm/Support/Error.h"
22#include <cstdint>
23#include <vector>
24
25namespace llvm {
26
27class BinaryStreamReader;
28class BinaryStreamWriter;
29
30namespace codeview {
31
32class DebugStringTableSubsection;
33
35 uint32_t FileNameOffset; // Byte offset of filename in global stringtable.
36 FileChecksumKind Kind; // The type of checksum.
37 ArrayRef<uint8_t> Checksum; // The bytes of the checksum.
38};
39
40} // end namespace codeview
41
42template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> {
43public:
44 using ContextType = void;
45
48};
49
50namespace codeview {
51
55
56public:
59
60 static bool classof(const DebugSubsectionRef *S) {
62 }
63
64 bool valid() const { return Checksums.valid(); }
65
68
69 Iterator begin() const { return Checksums.begin(); }
70 Iterator end() const { return Checksums.end(); }
71
72 const FileChecksumArray &getArray() const { return Checksums; }
73
74private:
75 FileChecksumArray Checksums;
76};
77
79public:
81
82 static bool classof(const DebugSubsection *S) {
83 return S->kind() == DebugSubsectionKind::FileChecksums;
84 }
85
86 void addChecksum(StringRef FileName, FileChecksumKind Kind,
87 ArrayRef<uint8_t> Bytes);
88
89 uint32_t calculateSerializedSize() const override;
90 Error commit(BinaryStreamWriter &Writer) const override;
91 uint32_t mapChecksumOffset(StringRef FileName) const;
92
93private:
95
97 uint32_t SerializedSize = 0;
98 BumpPtrAllocator Storage;
99 std::vector<FileChecksumEntry> Checksums;
100};
101
102} // end namespace codeview
103
104} // end namespace llvm
105
106#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H
This file defines the BumpPtrAllocator interface.
Lightweight arrays that are backed by an arbitrary BinaryStream.
#define LLVM_ABI
Definition: Compiler.h:213
This file defines the DenseMap class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Provides read only access to a subclass of BinaryStream.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Provides write only access to a subclass of WritableBinaryStream.
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
VarStreamArray represents an array of variable length records backed by a stream.
Iterator end() const
VarStreamArrayIterator< codeview::FileChecksumEntry, VarStreamArrayExtractor< codeview::FileChecksumEntry > > Iterator
Iterator begin(bool *HadError=nullptr) const
static bool classof(const DebugSubsectionRef *S)
LLVM_ABI Error initialize(BinaryStreamReader Reader)
static bool classof(const DebugSubsection *S)
Represents a read-write view of a CodeView string table.
DebugSubsectionKind kind() const
DebugSubsectionKind kind() const
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
LLVM_ABI Error operator()(BinaryStreamRef Stream, uint32_t &Len, codeview::FileChecksumEntry &Item)
VarStreamArrayExtractor is intended to be specialized to provide customized extraction logic.