LLVM 22.0.0git
DbiModuleList.h
Go to the documentation of this file.
1//===- DbiModuleList.h - PDB module information list ------------*- 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_PDB_NATIVE_DBIMODULELIST_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_DBIMODULELIST_H
11
12#include "llvm/ADT/StringRef.h"
13#include "llvm/ADT/iterator.h"
19#include "llvm/Support/Endian.h"
20#include "llvm/Support/Error.h"
21#include <cstddef>
22#include <cstdint>
23#include <iterator>
24#include <vector>
25
26namespace llvm {
27namespace pdb {
28
29class DbiModuleList;
30struct FileInfoSubstreamHeader;
31
33 : public iterator_facade_base<DbiModuleSourceFilesIterator,
34 std::random_access_iterator_tag, StringRef> {
35 using BaseType = typename DbiModuleSourceFilesIterator::iterator_facade_base;
36
37public:
39 uint32_t Modi, uint16_t Filei);
44
46
47 const StringRef &operator*() const { return ThisValue; }
48 StringRef &operator*() { return ThisValue; }
49
51 LLVM_ABI std::ptrdiff_t
55
56private:
57 void setValue();
58
59 bool isEnd() const;
60 bool isCompatible(const DbiModuleSourceFilesIterator &R) const;
61 bool isUniversalEnd() const;
62
63 StringRef ThisValue;
64 const DbiModuleList *Modules{nullptr};
65 uint32_t Modi{0};
66 uint16_t Filei{0};
67};
68
71
72public:
74
79
81 source_files(uint32_t Modi) const;
82
84
85private:
86 Error initializeModInfo(BinaryStreamRef ModInfo);
87 Error initializeFileInfo(BinaryStreamRef FileInfo);
88
90
93
94 // For each module, there are multiple filenames, which can be obtained by
95 // knowing the index of the file. Given the index of the file, one can use
96 // that as an offset into the FileNameOffsets array, which contains the
97 // absolute offset of the file name in NamesBuffer. Thus, for each module
98 // we store the first index in the FileNameOffsets array for this module.
99 // The number of files for the corresponding module is stored in
100 // ModFileCountArray.
101 std::vector<uint32_t> ModuleInitialFileIndex;
102
103 // In order to provide random access into the Descriptors array, we iterate it
104 // once up front to find the offsets of the individual items and store them in
105 // this array.
106 std::vector<uint32_t> ModuleDescriptorOffsets;
107
108 const FileInfoSubstreamHeader *FileInfoHeader = nullptr;
109
110 BinaryStreamRef ModInfoSubstream;
111 BinaryStreamRef FileInfoSubstream;
112 BinaryStreamRef NamesBuffer;
113};
114
115} // end namespace pdb
116} // end namespace llvm
117
118#endif // LLVM_DEBUGINFO_PDB_NATIVE_DBIMODULELIST_H
Lightweight arrays that are backed by an arbitrary BinaryStream.
#define LLVM_ABI
Definition: Compiler.h:213
uint32_t Index
Value * RHS
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
Tagged union holding either a T or a Error.
Definition: Error.h:485
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition: iterator.h:80
A range adaptor for a pair of iterators.
LLVM_ABI DbiModuleDescriptor getModuleDescriptor(uint32_t Modi) const
LLVM_ABI uint32_t getModuleCount() const
LLVM_ABI Error initialize(BinaryStreamRef ModInfo, BinaryStreamRef FileInfo)
LLVM_ABI uint32_t getSourceFileCount() const
LLVM_ABI iterator_range< DbiModuleSourceFilesIterator > source_files(uint32_t Modi) const
LLVM_ABI Expected< StringRef > getFileName(uint32_t Index) const
LLVM_ABI DbiModuleSourceFilesIterator & operator-=(std::ptrdiff_t N)
LLVM_ABI std::ptrdiff_t operator-(const DbiModuleSourceFilesIterator &R) const
LLVM_ABI bool operator==(const DbiModuleSourceFilesIterator &R) const
DbiModuleSourceFilesIterator(const DbiModuleSourceFilesIterator &R)=default
LLVM_ABI DbiModuleSourceFilesIterator & operator+=(std::ptrdiff_t N)
const StringRef & operator*() const
Definition: DbiModuleList.h:47
LLVM_ABI bool operator<(const DbiModuleSourceFilesIterator &RHS) const
DbiModuleSourceFilesIterator & operator=(const DbiModuleSourceFilesIterator &R)=default
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
#define N
The header preceding the File Info Substream of the DBI stream.
Definition: RawTypes.h:180