File indexing completed on 2026-05-10 08:43:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DWARFLINKER_INDEXEDVALUESMAP_H
0010 #define LLVM_DWARFLINKER_INDEXEDVALUESMAP_H
0011
0012 #include "llvm/ADT/DenseMap.h"
0013 #include "llvm/ADT/SmallVector.h"
0014 #include <cstdint>
0015 #include <utility>
0016
0017 namespace llvm {
0018 namespace dwarf_linker {
0019
0020
0021 template <typename T> class IndexedValuesMap {
0022 public:
0023 uint64_t getValueIndex(T Value) {
0024 auto [It, Inserted] = ValueToIndexMap.try_emplace(Value, Values.size());
0025 if (Inserted)
0026 Values.push_back(Value);
0027 return It->second;
0028 }
0029
0030 const SmallVector<T> &getValues() const { return Values; }
0031
0032 void clear() {
0033 ValueToIndexMap.clear();
0034 Values.clear();
0035 }
0036
0037 bool empty() { return Values.empty(); }
0038
0039 protected:
0040 using ValueToIndexMapTy = DenseMap<T, uint64_t>;
0041 ValueToIndexMapTy ValueToIndexMap;
0042 SmallVector<T> Values;
0043 };
0044
0045 }
0046 }
0047
0048 #endif