]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / PDB / Native / NamedStreamMap.h
1 //===- NamedStreamMap.h - PDB Named Stream Map ------------------*- 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_NAMEDSTREAMMAP_H
10 #define LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
11
12 #include "llvm/ADT/Optional.h"
13 #include "llvm/ADT/StringMap.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/ADT/iterator_range.h"
16 #include "llvm/DebugInfo/PDB/Native/HashTable.h"
17 #include "llvm/Support/Error.h"
18 #include <cstdint>
19
20 namespace llvm {
21
22 class BinaryStreamReader;
23 class BinaryStreamWriter;
24
25 namespace pdb {
26
27 class NamedStreamMap;
28
29 struct NamedStreamMapTraits {
30   NamedStreamMap *NS;
31
32   explicit NamedStreamMapTraits(NamedStreamMap &NS);
33   uint16_t hashLookupKey(StringRef S) const;
34   StringRef storageKeyToLookupKey(uint32_t Offset) const;
35   uint32_t lookupKeyToStorageKey(StringRef S);
36 };
37
38 class NamedStreamMap {
39   friend class NamedStreamMapBuilder;
40
41 public:
42   NamedStreamMap();
43
44   Error load(BinaryStreamReader &Stream);
45   Error commit(BinaryStreamWriter &Writer) const;
46   uint32_t calculateSerializedLength() const;
47
48   uint32_t size() const;
49   bool get(StringRef Stream, uint32_t &StreamNo) const;
50   void set(StringRef Stream, uint32_t StreamNo);
51
52   uint32_t appendStringData(StringRef S);
53   StringRef getString(uint32_t Offset) const;
54   uint32_t hashString(uint32_t Offset) const;
55
56   StringMap<uint32_t> entries() const;
57
58 private:
59   NamedStreamMapTraits HashTraits;
60   /// Closed hash table from Offset -> StreamNumber, where Offset is the offset
61   /// of the stream name in NamesBuffer.
62   HashTable<support::ulittle32_t> OffsetIndexMap;
63
64   /// Buffer of string data.
65   std::vector<char> NamesBuffer;
66 };
67
68 } // end namespace pdb
69
70 } // end namespace llvm
71
72 #endif // LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H