authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-05 21:39:15-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-05 21:39:15-05:00
log0c531d447df88ed6c46e759fbfc9d253d2650c22
treef2c83b6c7c099e155f3b1ff58186f907e5494126
parentbed83bc5a14aa6c0480dcfa842d97cce64427e1b

remove the boolean argument from setFnTest


5 files changed, 11 insertions(+), 29 deletions(-)

doc/langref.md+4
...@@ -616,3 +616,7 @@ or `switch` with compile time constants, and inline functions....@@ -616,3 +616,7 @@ or `switch` with compile time constants, and inline functions.
616### @intType(inline is_signed: bool, inline bit_count: u8) -> type616### @intType(inline is_signed: bool, inline bit_count: u8) -> type
617617
618This function returns an integer type with the given signness and bit count.618This function returns an integer type with the given signness and bit count.
619
620### @setFnTest(func)
621
622Makes the target function a test function.
src/all_types.hpp-2
...@@ -987,7 +987,6 @@ struct FnTableEntry {...@@ -987,7 +987,6 @@ struct FnTableEntry {
987987
988 AstNode *fn_no_inline_set_node;988 AstNode *fn_no_inline_set_node;
989 AstNode *fn_export_set_node;989 AstNode *fn_export_set_node;
990 AstNode *fn_test_set_node;
991 AstNode *fn_static_eval_set_node;990 AstNode *fn_static_eval_set_node;
992991
993 ZigList<IrInstruction *> alloca_list;992 ZigList<IrInstruction *> alloca_list;
...@@ -1674,7 +1673,6 @@ struct IrInstructionSetFnTest {...@@ -1674,7 +1673,6 @@ struct IrInstructionSetFnTest {
1674 IrInstruction base;1673 IrInstruction base;
16751674
1676 IrInstruction *fn_value;1675 IrInstruction *fn_value;
1677 IrInstruction *is_test;
1678};1676};
16791677
1680struct IrInstructionSetFnVisible {1678struct IrInstructionSetFnVisible {
src/codegen.cpp+1-1
...@@ -3083,7 +3083,7 @@ static void define_builtin_fns(CodeGen *g) {...@@ -3083,7 +3083,7 @@ static void define_builtin_fns(CodeGen *g) {
3083 create_builtin_fn_with_arg_count(g, BuiltinFnIdCompileErr, "compileError", 1);3083 create_builtin_fn_with_arg_count(g, BuiltinFnIdCompileErr, "compileError", 1);
3084 create_builtin_fn_with_arg_count(g, BuiltinFnIdIntType, "intType", 2);3084 create_builtin_fn_with_arg_count(g, BuiltinFnIdIntType, "intType", 2);
3085 create_builtin_fn_with_arg_count(g, BuiltinFnIdUnreachable, "unreachable", 0);3085 create_builtin_fn_with_arg_count(g, BuiltinFnIdUnreachable, "unreachable", 0);
3086 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnTest, "setFnTest", 2);3086 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnTest, "setFnTest", 1);
3087 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnVisible, "setFnVisible", 2);3087 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnVisible, "setFnVisible", 2);
3088 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnNoInline, "setFnNoInline", 2);3088 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnNoInline, "setFnNoInline", 2);
3089 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetDebugSafety, "setDebugSafety", 2);3089 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetDebugSafety, "setDebugSafety", 2);
src/ir.cpp+6-24
...@@ -934,15 +934,13 @@ static IrInstruction *ir_build_ptr_type_child(IrBuilder *irb, Scope *scope, AstN...@@ -934,15 +934,13 @@ static IrInstruction *ir_build_ptr_type_child(IrBuilder *irb, Scope *scope, AstN
934 return &instruction->base;934 return &instruction->base;
935}935}
936936
937static IrInstruction *ir_build_set_fn_test(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *fn_value,937static IrInstruction *ir_build_set_fn_test(IrBuilder *irb, Scope *scope, AstNode *source_node,
938 IrInstruction *is_test)938 IrInstruction *fn_value)
939{939{
940 IrInstructionSetFnTest *instruction = ir_build_instruction<IrInstructionSetFnTest>(irb, scope, source_node);940 IrInstructionSetFnTest *instruction = ir_build_instruction<IrInstructionSetFnTest>(irb, scope, source_node);
941 instruction->fn_value = fn_value;941 instruction->fn_value = fn_value;
942 instruction->is_test = is_test;
943942
944 ir_ref_instruction(fn_value);943 ir_ref_instruction(fn_value);
945 ir_ref_instruction(is_test);
946944
947 return &instruction->base;945 return &instruction->base;
948}946}
...@@ -1786,12 +1784,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo...@@ -1786,12 +1784,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
1786 if (arg0_value == irb->codegen->invalid_instruction)1784 if (arg0_value == irb->codegen->invalid_instruction)
1787 return arg0_value;1785 return arg0_value;
17881786
1789 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);1787 return ir_build_set_fn_test(irb, scope, node, arg0_value);
1790 IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope);
1791 if (arg1_value == irb->codegen->invalid_instruction)
1792 return arg1_value;
1793
1794 return ir_build_set_fn_test(irb, scope, node, arg0_value, arg1_value);
1795 }1788 }
1796 case BuiltinFnIdSetFnVisible:1789 case BuiltinFnIdSetFnVisible:
1797 {1790 {
...@@ -5680,26 +5673,15 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_test(IrAnalyze *ira,...@@ -5680,26 +5673,15 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_test(IrAnalyze *ira,
5680 IrInstructionSetFnTest *set_fn_test_instruction)5673 IrInstructionSetFnTest *set_fn_test_instruction)
5681{5674{
5682 IrInstruction *fn_value = set_fn_test_instruction->fn_value->other;5675 IrInstruction *fn_value = set_fn_test_instruction->fn_value->other;
5683 IrInstruction *is_test_value = set_fn_test_instruction->is_test->other;
56845676
5685 FnTableEntry *fn_entry = ir_resolve_fn(ira, fn_value);5677 FnTableEntry *fn_entry = ir_resolve_fn(ira, fn_value);
5686 if (!fn_entry)5678 if (!fn_entry)
5687 return ira->codegen->builtin_types.entry_invalid;5679 return ira->codegen->builtin_types.entry_invalid;
56885680
5689 if (!ir_resolve_bool(ira, is_test_value, &fn_entry->is_test))5681 if (!fn_entry->is_test) {
5690 return ira->codegen->builtin_types.entry_invalid;5682 fn_entry->is_test = true;
5691
5692 AstNode *source_node = set_fn_test_instruction->base.source_node;
5693 if (fn_entry->fn_test_set_node) {
5694 ErrorMsg *msg = add_node_error(ira->codegen, source_node,
5695 buf_sprintf("function test attribute set twice"));
5696 add_error_note(ira->codegen, msg, fn_entry->fn_test_set_node, buf_sprintf("first set here"));
5697 return ira->codegen->builtin_types.entry_invalid;
5698 }
5699 fn_entry->fn_test_set_node = source_node;
5700
5701 if (fn_entry->is_test)
5702 ira->codegen->test_fn_count += 1;5683 ira->codegen->test_fn_count += 1;
5684 }
57035685
5704 ir_build_const_from(ira, &set_fn_test_instruction->base, false);5686 ir_build_const_from(ira, &set_fn_test_instruction->base, false);
5705 return ira->codegen->builtin_types.entry_void;5687 return ira->codegen->builtin_types.entry_void;
src/ir_print.cpp-2
...@@ -491,8 +491,6 @@ static void ir_print_enum_field_ptr(IrPrint *irp, IrInstructionEnumFieldPtr *ins...@@ -491,8 +491,6 @@ static void ir_print_enum_field_ptr(IrPrint *irp, IrInstructionEnumFieldPtr *ins
491static void ir_print_set_fn_test(IrPrint *irp, IrInstructionSetFnTest *instruction) {491static void ir_print_set_fn_test(IrPrint *irp, IrInstructionSetFnTest *instruction) {
492 fprintf(irp->f, "@setFnTest(");492 fprintf(irp->f, "@setFnTest(");
493 ir_print_other_instruction(irp, instruction->fn_value);493 ir_print_other_instruction(irp, instruction->fn_value);
494 fprintf(irp->f, ", ");
495 ir_print_other_instruction(irp, instruction->is_test);
496 fprintf(irp->f, ")");494 fprintf(irp->f, ")");
497}495}
498496