LLVM  9.0.0svn
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"
18 #include "llvm/Support/Endian.h"
19 #include "llvm/Support/Error.h"
20 #include <cstddef>
21 #include <cstdint>
22 #include <iterator>
23 #include <vector>
24 
25 namespace llvm {
26 namespace pdb {
27 
28 class DbiModuleList;
29 struct FileInfoSubstreamHeader;
30 
32  : public iterator_facade_base<DbiModuleSourceFilesIterator,
33  std::random_access_iterator_tag, StringRef> {
34  using BaseType =
36  std::random_access_iterator_tag, StringRef>;
37 
38 public:
40  uint16_t Filei);
41  DbiModuleSourceFilesIterator() = default;
42  DbiModuleSourceFilesIterator &
43  operator=(const DbiModuleSourceFilesIterator &R) = default;
44 
45  bool operator==(const DbiModuleSourceFilesIterator &R) const;
46 
47  const StringRef &operator*() const { return ThisValue; }
48  StringRef &operator*() { return ThisValue; }
49 
50  bool operator<(const DbiModuleSourceFilesIterator &RHS) const;
51  std::ptrdiff_t operator-(const DbiModuleSourceFilesIterator &R) const;
52  DbiModuleSourceFilesIterator &operator+=(std::ptrdiff_t N);
53  DbiModuleSourceFilesIterator &operator-=(std::ptrdiff_t N);
54 
55 private:
56  void setValue();
57 
58  bool isEnd() const;
59  bool isCompatible(const DbiModuleSourceFilesIterator &R) const;
60  bool isUniversalEnd() const;
61 
62  StringRef ThisValue;
63  const DbiModuleList *Modules{nullptr};
64  uint32_t Modi{0};
65  uint16_t Filei{0};
66 };
67 
70 
71 public:
73 
75  uint32_t getModuleCount() const;
76  uint32_t getSourceFileCount() const;
77  uint16_t getSourceFileCount(uint32_t Modi) const;
78 
80  source_files(uint32_t Modi) const;
81 
82  DbiModuleDescriptor getModuleDescriptor(uint32_t Modi) const;
83 
84 private:
85  Error initializeModInfo(BinaryStreamRef ModInfo);
86  Error initializeFileInfo(BinaryStreamRef FileInfo);
87 
89 
92 
93  // For each module, there are multiple filenames, which can be obtained by
94  // knowing the index of the file. Given the index of the file, one can use
95  // that as an offset into the FileNameOffsets array, which contains the
96  // absolute offset of the file name in NamesBuffer. Thus, for each module
97  // we store the first index in the FileNameOffsets array for this module.
98  // The number of files for the corresponding module is stored in
99  // ModFileCountArray.
100  std::vector<uint32_t> ModuleInitialFileIndex;
101 
102  // In order to provide random access into the Descriptors array, we iterate it
103  // once up front to find the offsets of the individual items and store them in
104  // this array.
105  std::vector<uint32_t> ModuleDescriptorOffsets;
106 
107  const FileInfoSubstreamHeader *FileInfoHeader = nullptr;
108 
109  BinaryStreamRef ModInfoSubstream;
110  BinaryStreamRef FileInfoSubstream;
111  BinaryStreamRef NamesBuffer;
112 };
113 
114 } // end namespace pdb
115 } // end namespace llvm
116 
117 #endif // LLVM_DEBUGINFO_PDB_NATIVE_DBIMODULELIST_H
DbiModuleSourceFilesIterator & operator-=(std::ptrdiff_t N)
This class represents lattice values for constants.
Definition: AllocatorList.h:23
DbiModuleSourceFilesIterator & operator+=(std::ptrdiff_t N)
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
Tagged union holding either a T or a Error.
Definition: CachePruning.h:22
DbiModuleSourceFilesIterator & operator=(const DbiModuleSourceFilesIterator &R)=default
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition: iterator.h:67
static Expected< StringRef > getFileName(const DebugStringTableSubsectionRef &Strings, const DebugChecksumsSubsectionRef &Checksums, uint32_t FileID)
bool operator==(const DbiModuleSourceFilesIterator &R) const
The header preceding the File Info Substream of the DBI stream.
Definition: RawTypes.h:180
std::ptrdiff_t operator-(const DbiModuleSourceFilesIterator &R) const
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
A range adaptor for a pair of iterators.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringRef > StandardNames)
Initialize the set of available library functions based on the specified target triple.
const StringRef & operator*() const
Definition: DbiModuleList.h:47
#define N
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
bool operator<(const DbiModuleSourceFilesIterator &RHS) const