1//===- Streamutil.h - PDB stream utilities ----------------------*- 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_TOOLS_LLVMPDBDUMP_STREAMUTIL_H
10#define LLVM_TOOLS_LLVMPDBDUMP_STREAMUTIL_H
11
12#include "llvm/ADT/SmallVector.h"
13#include "llvm/ADT/StringRef.h"
14
15#include <string>
16#include <optional>
17
18namespace llvm {
19namespace pdb {
20class PDBFile;
21enum class StreamPurpose {
22 NamedStream,
23 ModuleStream,
24 Symbols,
25 PDB,
26 DBI,
27 TPI,
28 IPI,
29 DXContainer,
30 GlobalHash,
31 PublicHash,
32 TpiHash,
33 IpiHash,
34 Other
35};
36
37struct StreamInfo {
38public:
39 StreamInfo() = default;
40
41 uint32_t getModuleIndex() const { return *ModuleIndex; }
42 StreamPurpose getPurpose() const { return Purpose; }
43 StringRef getShortName() const { return Name; }
44 uint32_t getStreamIndex() const { return StreamIndex; }
45 std::string getLongName() const;
46
47 static StreamInfo createStream(StreamPurpose Purpose, StringRef Name,
48 uint32_t StreamIndex);
49 static StreamInfo createModuleStream(StringRef Module, uint32_t StreamIndex,
50 uint32_t Modi);
51
52private:
53 StreamPurpose Purpose;
54 uint32_t StreamIndex;
55 std::string Name;
56 std::optional<uint32_t> ModuleIndex;
57};
58
59void discoverStreamPurposes(PDBFile &File,
60 SmallVectorImpl<StreamInfo> &Streams);
61}
62}
63
64#endif
65