From 924faa58b43b5e727436cd50bded45b9c43ac3a4 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 5 Nov 2021 16:45:27 +0000 Subject: [PATCH] Correct `map_remove(PtrMap)` --- src/checker.cpp | 18 +++++++++--------- src/checker.hpp | 2 +- src/ptr_map.cpp | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/checker.cpp b/src/checker.cpp index 643673afe..044342760 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1086,7 +1086,7 @@ Scope *scope_of_node(Ast *node) { } ExprInfo *check_get_expr_info(CheckerContext *c, Ast *expr) { if (c->untyped != nullptr) { - ExprInfo **found = map_get(c->untyped, hash_pointer(expr)); + ExprInfo **found = map_get(c->untyped, expr); if (found) { return *found; } @@ -1094,7 +1094,7 @@ ExprInfo *check_get_expr_info(CheckerContext *c, Ast *expr) { } else { mutex_lock(&c->info->global_untyped_mutex); defer (mutex_unlock(&c->info->global_untyped_mutex)); - ExprInfo **found = map_get(&c->info->global_untyped, hash_pointer(expr)); + ExprInfo **found = map_get(&c->info->global_untyped, expr); if (found) { return *found; } @@ -1104,23 +1104,23 @@ ExprInfo *check_get_expr_info(CheckerContext *c, Ast *expr) { void check_set_expr_info(CheckerContext *c, Ast *expr, AddressingMode mode, Type *type, ExactValue value) { if (c->untyped != nullptr) { - map_set(c->untyped, hash_pointer(expr), make_expr_info(mode, type, value, false)); + map_set(c->untyped, expr, make_expr_info(mode, type, value, false)); } else { mutex_lock(&c->info->global_untyped_mutex); - map_set(&c->info->global_untyped, hash_pointer(expr), make_expr_info(mode, type, value, false)); + map_set(&c->info->global_untyped, expr, make_expr_info(mode, type, value, false)); mutex_unlock(&c->info->global_untyped_mutex); } } void check_remove_expr_info(CheckerContext *c, Ast *e) { if (c->untyped != nullptr) { - map_remove(c->untyped, hash_pointer(e)); - GB_ASSERT(map_get(c->untyped, hash_pointer(e)) == nullptr); + map_remove(c->untyped, e); + GB_ASSERT(map_get(c->untyped, e) == nullptr); } else { auto *untyped = &c->info->global_untyped; mutex_lock(&c->info->global_untyped_mutex); - map_remove(untyped, hash_pointer(e)); - GB_ASSERT(map_get(untyped, hash_pointer(e)) == nullptr); + map_remove(untyped, e); + GB_ASSERT(map_get(untyped, e) == nullptr); mutex_unlock(&c->info->global_untyped_mutex); } } @@ -4952,7 +4952,7 @@ void add_untyped_expressions(CheckerInfo *cinfo, UntypedExprInfoMap *untyped) { return; } for_array(i, untyped->entries) { - Ast *expr = cast(Ast *)cast(uintptr)untyped->entries[i].key.key; + Ast *expr = untyped->entries[i].key; ExprInfo *info = untyped->entries[i].value; if (expr != nullptr && info != nullptr) { mpmc_enqueue(&cinfo->checker->global_untyped_queue, UntypedExprInfo{expr, info}); diff --git a/src/checker.hpp b/src/checker.hpp index e7f152eb2..700cd7e54 100644 --- a/src/checker.hpp +++ b/src/checker.hpp @@ -264,7 +264,7 @@ struct UntypedExprInfo { ExprInfo *info; }; -typedef Map UntypedExprInfoMap; // Key: Ast * +typedef PtrMap UntypedExprInfoMap; typedef MPMCQueue ProcBodyQueue; // CheckerInfo stores all the symbol information for a type-checked program diff --git a/src/ptr_map.cpp b/src/ptr_map.cpp index af3cf86f9..153b40b7e 100644 --- a/src/ptr_map.cpp +++ b/src/ptr_map.cpp @@ -219,7 +219,7 @@ void map__erase(PtrMap *h, MapFindResult const &fr) { } template -void map_remove(PtrMap *h, HashKey const &key) { +void map_remove(PtrMap *h, K key) { MapFindResult fr = map__find(h, key); if (fr.entry_index != MAP_SENTINEL) { map__erase(h, fr);