File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,9 +13,8 @@ class UntypedTrapLabel {
1313 uint64_t id_;
1414
1515 friend class std ::hash<UntypedTrapLabel>;
16-
17- // we want to have access to the untyped, underlying id
18- friend class TrapLabelStore ;
16+ template <typename Tag>
17+ friend class TrapLabel ;
1918
2019 protected:
2120 UntypedTrapLabel () : id_{0xffffffffffffffff } {}
@@ -44,6 +43,7 @@ class TrapLabel : public UntypedTrapLabel {
4443
4544 // The caller is responsible for ensuring ID uniqueness.
4645 static TrapLabel unsafeCreateFromExplicitId (uint64_t id) { return {id}; }
46+ static TrapLabel unsafeCreateFromUntyped (UntypedTrapLabel label) { return {label.id_ }; }
4747
4848 template <typename OtherTag>
4949 TrapLabel (const TrapLabel<OtherTag>& other) : UntypedTrapLabel(other) {
Original file line number Diff line number Diff line change @@ -41,19 +41,19 @@ class TrapLabelStore {
4141 template <typename T>
4242 std::optional<TrapLabel<ToTag<T>>> get (const T* e) {
4343 if (auto found = store_.find (getCanonicalPtr (e)); found != store_.end ()) {
44- return TrapLabel<ToTag<T>>::unsafeCreateFromExplicitId (found->second );
44+ return TrapLabel<ToTag<T>>::unsafeCreateFromUntyped (found->second );
4545 }
4646 return std::nullopt ;
4747 }
4848
4949 template <typename T>
5050 void insert (const T* e, TrapLabel<ToTag<T>> l) {
51- auto [_, inserted] = store_.emplace (getCanonicalPtr (e), l. id_ );
51+ auto [_, inserted] = store_.emplace (getCanonicalPtr (e), l);
5252 assert (inserted && " already inserted" );
5353 }
5454
5555 private:
56- std::unordered_map<const void *, uint64_t > store_;
56+ std::unordered_map<const void *, UntypedTrapLabel > store_;
5757};
5858
5959} // namespace codeql
You can’t perform that action at this time.
0 commit comments