diff options
| author | Harold Brenes <harold@hbrenes.com> | 2025-05-03 01:50:19 -0400 |
|---|---|---|
| committer | Harold Brenes <harold@hbrenes.com> | 2025-05-03 03:09:31 -0400 |
| commit | 33d37c72f9750d8249ba1d31b5ef9d3a88c54f0a (patch) | |
| tree | 5dea39cf1cb143caaa1bf3f7b94607771afd624a /src/llvm_backend.cpp | |
| parent | a00b91577d998b3795afd099504a6c2b9d99460e (diff) | |
Register all classes unconditionally
Diffstat (limited to 'src/llvm_backend.cpp')
| -rw-r--r-- | src/llvm_backend.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index a7082972a..4396a2a27 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -1515,6 +1515,12 @@ gb_internal void lb_finalize_objc_names(lbGenerator *gen, lbProcedure *p) { auto args = array_make<lbValue>(temporary_allocator(), 3, 8); auto class_impls = array_make<lbObjCGlobalClass>(temporary_allocator(), 0, 16); + // Register all class implementations unconditionally, even if not statically referenced + for (Entity *e = {}; mpsc_dequeue(&gen->info->objc_class_implementations, &e); /**/) { + GB_ASSERT(e->kind == Entity_TypeName && e->TypeName.objc_is_implementation); + lb_handle_objc_find_or_register_class(p, e->TypeName.objc_class_name, e->type); + } + // Ensure classes that have been implicitly referenced through // the objc_superclass attribute have a global variable available for them. TypeSet class_set{}; @@ -1523,7 +1529,7 @@ gb_internal void lb_finalize_objc_names(lbGenerator *gen, lbProcedure *p) { auto referenced_classes = array_make<lbObjCGlobal>(temporary_allocator()); for (lbObjCGlobal g = {}; mpsc_dequeue(&gen->objc_classes, &g); /**/) { - array_add( &referenced_classes, g); + array_add(&referenced_classes, g); Type *cls = g.class_impl_type; while (cls) { @@ -1547,7 +1553,7 @@ gb_internal void lb_finalize_objc_names(lbGenerator *gen, lbProcedure *p) { // Add all class globals to a map so that we can look them up dynamically // in order to resolve out-of-order because classes that are being implemented - // need their superclasses to have been registered before them. + // require their superclasses to be registered before them. StringMap<lbObjCGlobalClass> global_class_map{}; string_map_init(&global_class_map, (usize)gen->objc_classes.count); defer (string_map_destroy(&global_class_map)); |