diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-10 20:37:39 +0100 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-10 20:37:39 +0100 |
| commit | d3602ca634061bda4561a05c37f4fe3a828ad1e6 (patch) | |
| tree | a838c7c3d2b405d3175927cfcbc6850e4618bc58 /src | |
| parent | 76c0f895350c9468c143fd280ec169cb900a374f (diff) | |
Removal of some old checks
Diffstat (limited to 'src')
| -rw-r--r-- | src/checker.cpp | 83 |
1 files changed, 48 insertions, 35 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index 934e6282b..e451a38e1 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -2997,7 +2997,6 @@ gb_internal void generate_minimum_dependency_set(Checker *c, Entity *start) { } gb_internal gb_inline bool is_entity_a_dependency(Entity *e) { - if (e == nullptr) return false; switch (e->kind) { case Entity_Procedure: return true; @@ -3026,7 +3025,7 @@ gb_internal Array<EntityGraphNode *> generate_entity_dependency_graph(CheckerInf for_array(i, info->entities) { Entity *e = info->entities[i]; - if (!is_entity_a_dependency(e)) { + if (e == nullptr || !is_entity_a_dependency(e)) { continue; } EntityGraphNode *n = arena_alloc_item<EntityGraphNode>(arena); @@ -3048,10 +3047,10 @@ gb_internal Array<EntityGraphNode *> generate_entity_dependency_graph(CheckerInf GB_ASSERT(decl != nullptr); FOR_PTR_SET(dep, decl->deps) { + GB_ASSERT(dep != nullptr); if (dep->flags & EntityFlag_Field) { continue; } - GB_ASSERT(dep != nullptr); if (!is_entity_a_dependency(dep)) { continue; } @@ -7129,13 +7128,18 @@ gb_internal void check_sort_init_and_fini_procedures(Checker *c) { } gb_internal void add_type_info_for_type_definitions(Checker *c) { - for_array(i, c->info.definitions) { - Entity *e = c->info.definitions[i]; + for (Entity *e : c->info.definitions) { if (e->kind == Entity_TypeName && e->type != nullptr && is_type_typed(e->type)) { + #if 0 i64 align = type_align_of(e->type); if (align > 0 && e->min_dep_count.load(std::memory_order_relaxed) > 0) { add_type_info_type(&c->builtin_ctx, e->type); } + #else + if (e->min_dep_count.load(std::memory_order_relaxed) > 0) { + add_type_info_type(&c->builtin_ctx, e->type); + } + #endif } } } @@ -7232,6 +7236,43 @@ gb_internal void check_all_scope_usages(Checker *c) { } +gb_internal void check_for_type_cycles(Checker *c) { + // NOTE(bill): Check for illegal cyclic type declarations + for_array(i, c->info.definitions) { + Entity *e = c->info.definitions[i]; + if (e->kind != Entity_TypeName) { + continue; + } + if (e->type != nullptr && is_type_typed(e->type)) { + if (e->TypeName.is_type_alias) { + // Ignore for the time being + } else { + (void)type_align_of(e->type); + } + } + } +} + +gb_internal void check_for_inline_cycles(Checker *c) { + for_array(i, c->info.definitions) { + Entity *e = c->info.definitions[i]; + if (e->kind != Entity_Procedure) { + continue; + } + DeclInfo *decl = e->decl_info; + ast_node(pl, ProcLit, decl->proc_lit); + if (pl->inlining == ProcInlining_inline) { + FOR_PTR_SET(dep, decl->deps) { + if (dep == e) { + error(e->token, "Cannot inline recursive procedure '%.*s'", LIT(e->token.string)); + break; + } + } + } + } +} + + gb_internal void check_parsed_files(Checker *c) { global_checker_ptr.store(c, std::memory_order_relaxed); @@ -7314,38 +7355,10 @@ gb_internal void check_parsed_files(Checker *c) { check_merge_queues_into_arrays(c); TIME_SECTION("check for type cycles"); - // NOTE(bill): Check for illegal cyclic type declarations - for_array(i, c->info.definitions) { - Entity *e = c->info.definitions[i]; - if (e->kind != Entity_TypeName) { - continue; - } - if (e->type != nullptr && is_type_typed(e->type)) { - if (e->TypeName.is_type_alias) { - // Ignore for the time being - } else { - (void)type_align_of(e->type); - } - } - } + check_for_type_cycles(c); TIME_SECTION("check for inline cycles"); - for_array(i, c->info.definitions) { - Entity *e = c->info.definitions[i]; - if (e->kind != Entity_Procedure) { - continue; - } - DeclInfo *decl = e->decl_info; - ast_node(pl, ProcLit, decl->proc_lit); - if (pl->inlining == ProcInlining_inline) { - FOR_PTR_SET(dep, decl->deps) { - if (dep == e) { - error(e->token, "Cannot inline recursive procedure '%.*s'", LIT(e->token.string)); - break; - } - } - } - } + check_for_inline_cycles(c); TIME_SECTION("check deferred procedures"); check_deferred_procedures(c); |