LLVM  9.0.0svn
NamedStreamMap.h
Go to the documentation of this file.
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"
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 
31 
33  uint16_t hashLookupKey(StringRef S) const;
36 };
37 
39  friend class NamedStreamMapBuilder;
40 
41 public:
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
This class represents lattice values for constants.
Definition: AllocatorList.h:23
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
StringRef storageKeyToLookupKey(uint32_t Offset) const
uint16_t hashLookupKey(StringRef S) const
uint32_t lookupKeyToStorageKey(StringRef S)
Provides write only access to a subclass of WritableBinaryStream.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
Definition: STLExtras.h:1173
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
NamedStreamMapTraits(NamedStreamMap &NS)