From fa7c64ccd511703fef9971c4d07c447c9aeda49c Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Mar 2017 11:24:58 -0400 Subject: lazy analysis of top level declarations previously, we had lazy analysis of top level declarations, but if a declaration was referenced within a compile-time if or switch statement, that would still add the top level declaration to the resolution queue. now we have a declref ir instruction, which is only resolved if we analyze the instruction. this takes into account comptime branching. closes #270 --- src/ir_print.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/ir_print.cpp') diff --git a/src/ir_print.cpp b/src/ir_print.cpp index b5f5a16983..8365aec050 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -849,6 +849,13 @@ static void ir_print_set_global_section(IrPrint *irp, IrInstructionSetGlobalSect fprintf(irp->f, ")"); } +static void ir_print_decl_ref(IrPrint *irp, IrInstructionDeclRef *instruction) { + const char *ptr_str = instruction->lval.is_ptr ? "ptr " : ""; + const char *const_str = instruction->lval.is_const ? "const " : ""; + const char *volatile_str = instruction->lval.is_volatile ? "volatile " : ""; + fprintf(irp->f, "declref %s%s%s%s", const_str, volatile_str, ptr_str, buf_ptr(instruction->tld->name)); +} + static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { ir_print_prefix(irp, instruction); switch (instruction->id) { @@ -1121,6 +1128,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { case IrInstructionIdSetGlobalSection: ir_print_set_global_section(irp, (IrInstructionSetGlobalSection *)instruction); break; + case IrInstructionIdDeclRef: + ir_print_decl_ref(irp, (IrInstructionDeclRef *)instruction); + break; } fprintf(irp->f, "\n"); } -- cgit v1.2.3