LLVM  8.0.1
NamedStreamMap.h
Go to the documentation of this file.
1 //===- NamedStreamMap.h - PDB Named Stream Map ------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
11 #define LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
12 
13 #include "llvm/ADT/Optional.h"
14 #include "llvm/ADT/StringMap.h"
15 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Support/Error.h"
19 #include <cstdint>
20 
21 namespace llvm {
22 
23 class BinaryStreamReader;
24 class BinaryStreamWriter;
25 
26 namespace pdb {
27 
28 class NamedStreamMap;
29 
32 
34  uint16_t hashLookupKey(StringRef S) const;
37 };
38 
40  friend class NamedStreamMapBuilder;
41 
42 public:
44 
45  Error load(BinaryStreamReader &Stream);
46  Error commit(BinaryStreamWriter &Writer) const;
47  uint32_t calculateSerializedLength() const;
48 
49  uint32_t size() const;
50  bool get(StringRef Stream, uint32_t &StreamNo) const;
51  void set(StringRef Stream, uint32_t StreamNo);
52 
53  uint32_t appendStringData(StringRef S);
54  StringRef getString(uint32_t Offset) const;
55  uint32_t hashString(uint32_t Offset) const;
56 
57  StringMap<uint32_t> entries() const;
58 
59 private:
60  NamedStreamMapTraits HashTraits;
61  /// Closed hash table from Offset -> StreamNumber, where Offset is the offset
62  /// of the stream name in NamesBuffer.
64 
65  /// Buffer of string data.
66  std::vector<char> NamesBuffer;
67 };
68 
69 } // end namespace pdb
70 
71 } // end namespace llvm
72 
73 #endif // LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
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:1167
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
NamedStreamMapTraits(NamedStreamMap &NS)