Correct map_remove(PtrMap)

This commit is contained in:
gingerBill
2021-11-05 16:45:27 +00:00
parent 6be104e521
commit 924faa58b4
3 changed files with 11 additions and 11 deletions
+9 -9
View File
@@ -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});
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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);