From 18ec4c1eac821b6f716678ff9a1a233598d8161a Mon Sep 17 00:00:00 2001 From: David Mak Date: Mon, 12 Aug 2024 16:41:30 +0800 Subject: [PATCH] WIP10 - Add debug assertions to printf --- nac3artiq/src/codegen.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index cf4f2627..24b35f45 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -748,6 +748,9 @@ fn polymorphic_print<'ctx>( generator: &mut dyn CodeGenerator, fmt: String, args: Vec>| { + debug_assert!(!fmt.is_empty()); + debug_assert_eq!(fmt.as_bytes().last().unwrap(), &0u8); + let fn_name = if as_rtio { "rtio_log" } else { "core_log" }; let print_fn = ctx.module.get_function(fn_name).unwrap_or_else(|| { let llvm_pi8 = ctx.ctx.i8_type().ptr_type(AddressSpace::default());