File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,8 @@ class UntypedTrapLabel {
13
13
uint64_t id_;
14
14
15
15
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 ;
19
18
20
19
protected:
21
20
UntypedTrapLabel () : id_{0xffffffffffffffff } {}
@@ -44,6 +43,7 @@ class TrapLabel : public UntypedTrapLabel {
44
43
45
44
// The caller is responsible for ensuring ID uniqueness.
46
45
static TrapLabel unsafeCreateFromExplicitId (uint64_t id) { return {id}; }
46
+ static TrapLabel unsafeCreateFromUntyped (UntypedTrapLabel label) { return {label.id_ }; }
47
47
48
48
template <typename OtherTag>
49
49
TrapLabel (const TrapLabel<OtherTag>& other) : UntypedTrapLabel(other) {
Original file line number Diff line number Diff line change @@ -41,19 +41,19 @@ class TrapLabelStore {
41
41
template <typename T>
42
42
std::optional<TrapLabel<ToTag<T>>> get (const T* e) {
43
43
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 );
45
45
}
46
46
return std::nullopt;
47
47
}
48
48
49
49
template <typename T>
50
50
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);
52
52
assert (inserted && " already inserted" );
53
53
}
54
54
55
55
private:
56
- std::unordered_map<const void *, uint64_t > store_;
56
+ std::unordered_map<const void *, UntypedTrapLabel > store_;
57
57
};
58
58
59
59
} // namespace codeql
You can’t perform that action at this time.
0 commit comments