Fix poly proc determination by cloning the signature node

This commit is contained in:
gingerBill
2018-11-25 17:57:49 +00:00
parent c2f9bf489e
commit 9b063ad9a3
3 changed files with 23 additions and 21 deletions

View File

@@ -278,7 +278,6 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *c, Entity *base_enti
return false;
}
auto *found_gen_procs = map_get(&nctx.info->gen_procs, hash_pointer(base_entity->identifier));
if (found_gen_procs) {
auto procs = *found_gen_procs;
@@ -304,13 +303,14 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *c, Entity *base_enti
// NOTE(bill): Reset scope from the failed procedure type
scope_reset(scope);
success = check_procedure_type(&nctx, final_proc_type, pt->node, &operands);
// LEAK TODO(bill): Cloning this AST may be leaky
Ast *cloned_proc_type_node = clone_ast(pt->node);
success = check_procedure_type(&nctx, final_proc_type, cloned_proc_type_node, &operands);
if (!success) {
return false;
}
if (found_gen_procs) {
auto procs = *found_gen_procs;
for_array(i, procs) {

View File

@@ -763,7 +763,7 @@ extern "C++" {
#ifndef GB_ASSERT_MSG
#define GB_ASSERT_MSG(cond, msg, ...) do { \
if (!(cond)) { \
gb_assert_handler(#cond, __FILE__, cast(i64)__LINE__, msg, ##__VA_ARGS__); \
gb_assert_handler("Assertion Failure", #cond, __FILE__, cast(i64)__LINE__, msg, ##__VA_ARGS__); \
GB_DEBUG_TRAP(); \
} \
} while (0)
@@ -779,10 +779,13 @@ extern "C++" {
// NOTE(bill): Things that shouldn't happen with a message!
#ifndef GB_PANIC
#define GB_PANIC(msg, ...) GB_ASSERT_MSG(0, msg, ##__VA_ARGS__)
#define GB_PANIC(msg, ...) do { \
gb_assert_handler("Panic", NULL, __FILE__, cast(i64)__LINE__, msg, ##__VA_ARGS__); \
GB_DEBUG_TRAP(); \
} while (0)
#endif
GB_DEF void gb_assert_handler(char const *condition, char const *file, i32 line, char const *msg, ...);
GB_DEF void gb_assert_handler(char const *prefix, char const *condition, char const *file, i32 line, char const *msg, ...);
@@ -3613,8 +3616,8 @@ extern "C" {
#pragma warning(disable:4127) // Conditional expression is constant
#endif
void gb_assert_handler(char const *condition, char const *file, i32 line, char const *msg, ...) {
gb_printf_err("%s(%d): Assert Failure: ", file, line);
void gb_assert_handler(char const *prefix, char const *condition, char const *file, i32 line, char const *msg, ...) {
gb_printf_err("%s(%d): %s: ", file, line, prefix);
if (condition)
gb_printf_err( "`%s` ", condition);
if (msg) {

View File

@@ -2593,21 +2593,20 @@ irDebugInfo *ir_add_debug_info_proc(irProcedure *proc) {
irDebugInfo *ir_add_debug_info_location(irModule *m, Ast *node, irDebugInfo *scope, Entity *e) {
if (node == nullptr || scope == nullptr) {
if (e == nullptr) {
return nullptr;
} else if (scope != nullptr) {
irDebugInfo **existing = map_get(&m->debug_info, hash_entity(e));
if (existing != nullptr) {
return *existing;
}
if (e != nullptr && scope != nullptr) {
// irDebugInfo **existing = map_get(&m->debug_info, hash_entity(e));
// if (existing != nullptr) {
// return *existing;
// }
// TODO HACK(bill): This is a little dirty but it is should do for the weird edge cases
irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_Location);
di->Location.pos = e->token.pos;
di->Location.scope = scope;
map_set(&m->debug_info, hash_entity(e), di);
return di;
// // TODO HACK(bill): This is a little dirty but it is should do for the weird edge cases
// irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_Location);
// di->Location.pos = e->token.pos;
// di->Location.scope = scope;
// map_set(&m->debug_info, hash_entity(e), di);
// return di;
}
return nullptr;
}
// TODO(lachsinc): Should we traverse the node/children until we find one with
// valid token/pos and use that instead??