From 2ee80858b42796c931fb2fe0b45e0ebb6f8ffb30 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 5 Feb 2016 14:48:23 -0700 Subject: codegen: use gen_index for nonnull attribute also put nonnull on sret params closes #82 --- src/codegen.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 2965c8e593..d002c716ef 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -2876,6 +2876,7 @@ static void do_code_gen(CodeGen *g) { if (handle_is_ptr(fn_type->data.fn.fn_type_id.return_type)) { LLVMValueRef first_arg = LLVMGetParam(fn_table_entry->fn_value, 0); LLVMAddAttribute(first_arg, LLVMStructRetAttribute); + LLVMZigAddNonNullAttr(fn_table_entry->fn_value, 1); } // set parameter attributes @@ -2903,12 +2904,7 @@ static void do_code_gen(CodeGen *g) { LLVMAddAttribute(argument_val, LLVMReadOnlyAttribute); } if (param_type->id == TypeTableEntryIdPointer) { - // when https://github.com/andrewrk/zig/issues/82 is fixed, add - // non null attribute here - - ///`i` is arg index + 1 - ///I think that 0 is the return index, but it has a named LLVM constant variable - LLVMZigAddNonNullAttr(fn_table_entry->fn_value, param_decl_i + 1); + LLVMZigAddNonNullAttr(fn_table_entry->fn_value, gen_index + 1); } if (is_byval) { // TODO -- cgit v1.2.3