aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-11-05 16:45:27 +0000
committergingerBill <bill@gingerbill.org>2021-11-05 16:45:27 +0000
commit924faa58b43b5e727436cd50bded45b9c43ac3a4 (patch)
treefc57e83bf415f93c6ba875e6eb21f686f56962e0 /src
parent6be104e5215668aad05c68cb26e1dd9fe898fc11 (diff)
Correct `map_remove(PtrMap)`
Diffstat (limited to 'src')
-rw-r--r--src/checker.cpp18
-rw-r--r--src/checker.hpp2
-rw-r--r--src/ptr_map.cpp2
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<ExprInfo *> UntypedExprInfoMap; // Key: Ast *
+typedef PtrMap<Ast *, ExprInfo *> UntypedExprInfoMap;
typedef MPMCQueue<ProcInfo *> 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<K, V> *h, MapFindResult const &fr) {
}
template <typename K, typename V>
-void map_remove(PtrMap<K, V> *h, HashKey const &key) {
+void map_remove(PtrMap<K, V> *h, K key) {
MapFindResult fr = map__find(h, key);
if (fr.entry_index != MAP_SENTINEL) {
map__erase(h, fr);