@sprintf macro (based on the $$sprintf builtin) allows compile time format strings #1874.

This commit is contained in:
Christoffer Lerno
2025-06-06 03:18:28 +02:00
parent 9baeca3a8e
commit f2daf2e11e
17 changed files with 168 additions and 69 deletions

View File

@@ -0,0 +1,14 @@
// #target: macos-x64
module test;
fn void main()
{
var $foo = "hello";
var $c = { 1, 3 };
String x = $$sprintf("%s %s", $foo, $c);
String y = @sprintf("%s %s", $c, $foo);
}
/* #expect: test.ll
@.str = private unnamed_addr constant [13 x i8] c"hello {1, 3}\00", align 1
@.str.1 = private unnamed_addr constant [13 x i8] c"{1, 3} hello\00", align 1