Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:44

0001 //===- NamedStreamMap.h - PDB Named Stream Map ------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
0010 #define LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
0011 
0012 #include "llvm/ADT/StringMap.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include "llvm/DebugInfo/PDB/Native/HashTable.h"
0015 #include "llvm/Support/Error.h"
0016 #include <cstdint>
0017 
0018 namespace llvm {
0019 
0020 class BinaryStreamReader;
0021 class BinaryStreamWriter;
0022 
0023 namespace pdb {
0024 
0025 class NamedStreamMap;
0026 
0027 struct NamedStreamMapTraits {
0028   NamedStreamMap *NS;
0029 
0030   explicit NamedStreamMapTraits(NamedStreamMap &NS);
0031   uint16_t hashLookupKey(StringRef S) const;
0032   StringRef storageKeyToLookupKey(uint32_t Offset) const;
0033   uint32_t lookupKeyToStorageKey(StringRef S);
0034 };
0035 
0036 class NamedStreamMap {
0037   friend class NamedStreamMapBuilder;
0038 
0039 public:
0040   NamedStreamMap();
0041 
0042   Error load(BinaryStreamReader &Stream);
0043   Error commit(BinaryStreamWriter &Writer) const;
0044   uint32_t calculateSerializedLength() const;
0045 
0046   uint32_t size() const;
0047   bool get(StringRef Stream, uint32_t &StreamNo) const;
0048   void set(StringRef Stream, uint32_t StreamNo);
0049 
0050   uint32_t appendStringData(StringRef S);
0051   StringRef getString(uint32_t Offset) const;
0052   uint32_t hashString(uint32_t Offset) const;
0053 
0054   StringMap<uint32_t> entries() const;
0055 
0056 private:
0057   NamedStreamMapTraits HashTraits;
0058   /// Closed hash table from Offset -> StreamNumber, where Offset is the offset
0059   /// of the stream name in NamesBuffer.
0060   HashTable<support::ulittle32_t> OffsetIndexMap;
0061 
0062   /// Buffer of string data.
0063   std::vector<char> NamesBuffer;
0064 };
0065 
0066 } // end namespace pdb
0067 
0068 } // end namespace llvm
0069 
0070 #endif // LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H