1 //===- NamedStreamMap.h - PDB Named Stream Map ------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
10 #define LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
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"
22 class BinaryStreamReader
;
23 class BinaryStreamWriter
;
29 struct NamedStreamMapTraits
{
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
);
38 class NamedStreamMap
{
39 friend class NamedStreamMapBuilder
;
44 Error
load(BinaryStreamReader
&Stream
);
45 Error
commit(BinaryStreamWriter
&Writer
) const;
46 uint32_t calculateSerializedLength() const;
48 uint32_t size() const;
49 bool get(StringRef Stream
, uint32_t &StreamNo
) const;
50 void set(StringRef Stream
, uint32_t StreamNo
);
52 uint32_t appendStringData(StringRef S
);
53 StringRef
getString(uint32_t Offset
) const;
54 uint32_t hashString(uint32_t Offset
) const;
56 StringMap
<uint32_t> entries() const;
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
;
64 /// Buffer of string data.
65 std::vector
<char> NamesBuffer
;
68 } // end namespace pdb
70 } // end namespace llvm
72 #endif // LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H