authorgravatar for skewb1kunix@gmail.comskewb1k <skewb1kunix@gmail.com> 2025-11-03 03:29:16+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2025-11-05 14:07:30+02:00
log26db54d69b9a7f58a45897bb9523f95e3b8dd054
tree259fa6ddcdb874d3054ad76c3715361037b8109e
parenta6d444c2714f24b7232895cf15282e2287fe445e

zig fmt: fix extra whitespace in StructInit with multiline strings

68d2f68ed introduced special handling for StructInit fields containing multiline strings to prevent inserting whitespace after =. However, this logic didn't handle cases without a trailing comma, which resulted in unwanted trailing whitespace.

4 files changed, 102 insertions(+), 91 deletions(-)

lib/std/zig/Ast/Render.zig+2-1
......@@ -2056,7 +2056,8 @@ fn renderStructInit(
20562056 const init_token = tree.firstToken(field_init);
20572057 try renderToken(r, init_token - 3, .none); // .
20582058 try renderIdentifier(r, init_token - 2, .space, .eagerly_unquote); // name
2059 try renderToken(r, init_token - 1, .space); // =
2059 const space_after_equal: Space = if (tree.nodeTag(field_init) == .multiline_string_literal) .none else .space;
2060 try renderToken(r, init_token - 1, space_after_equal); // =
20602061 try renderExpressionFixup(r, field_init, .comma_space);
20612062 }
20622063 }
lib/std/zig/parser_test.zig+10
......@@ -5719,6 +5719,16 @@ test "zig fmt: no space before newline before multiline string" {
57195719 \\ ,
57205720 \\ };
57215721 \\ _ = s2;
5722 \\ const s3 = .{ .text =
5723 \\ \\hello
5724 \\ \\world
5725 \\ , .comment = "test" };
5726 \\ _ = s3;
5727 \\ const s4 = .{ .comment = "test", .text =
5728 \\ \\hello
5729 \\ \\world
5730 \\ };
5731 \\ _ = s4;
57225732 \\}
57235733 \\
57245734 );
test/link/elf.zig+12-12
......@@ -480,7 +480,7 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
480480fn testCommentString(b: *Build, opts: Options) *Step {
481481 const test_step = addTestStep(b, "comment-string", opts);
482482
483 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
483 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
484484 \\pub fn main() void {}
485485 });
486486
......@@ -495,7 +495,7 @@ fn testCommentString(b: *Build, opts: Options) *Step {
495495fn testCommentStringStaticLib(b: *Build, opts: Options) *Step {
496496 const test_step = addTestStep(b, "comment-string-static-lib", opts);
497497
498 const lib = addStaticLibrary(b, opts, .{ .name = "lib", .zig_source_bytes =
498 const lib = addStaticLibrary(b, opts, .{ .name = "lib", .zig_source_bytes =
499499 \\export fn foo() void {}
500500 });
501501
......@@ -866,7 +866,7 @@ fn testDsoUndef(b: *Build, opts: Options) *Step {
866866fn testEmitRelocatable(b: *Build, opts: Options) *Step {
867867 const test_step = addTestStep(b, "emit-relocatable", opts);
868868
869 const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
869 const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
870870 \\const std = @import("std");
871871 \\extern var bar: i32;
872872 \\export fn foo() i32 {
......@@ -878,7 +878,7 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
878878 });
879879 a_o.root_module.link_libc = true;
880880
881 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
881 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
882882 \\#include <stdio.h>
883883 \\int bar = 42;
884884 \\void printBar() {
......@@ -891,7 +891,7 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
891891 c_o.root_module.addObject(a_o);
892892 c_o.root_module.addObject(b_o);
893893
894 const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
894 const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
895895 \\const std = @import("std");
896896 \\extern fn printFoo() void;
897897 \\extern fn printBar() void;
......@@ -1925,7 +1925,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
19251925 });
19261926 g_o.root_module.link_libc = true;
19271927
1928 const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
1928 const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
19291929 \\#include <stdio.h>
19301930 \\__attribute__((destructor)) void fini2() { printf("8"); }
19311931 });
......@@ -2447,7 +2447,7 @@ fn testLinkingZig(b: *Build, opts: Options) *Step {
24472447fn testLinksection(b: *Build, opts: Options) *Step {
24482448 const test_step = addTestStep(b, "linksection", opts);
24492449
2450 const obj = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
2450 const obj = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
24512451 \\export var test_global: u32 linksection(".TestGlobal") = undefined;
24522452 \\export fn testFn() linksection(".TestFn") callconv(.c) void {
24532453 \\ TestGenericFn("A").f();
......@@ -2540,7 +2540,7 @@ fn testMergeStrings(b: *Build, opts: Options) *Step {
25402540fn testMergeStrings2(b: *Build, opts: Options) *Step {
25412541 const test_step = addTestStep(b, "merge-strings2", opts);
25422542
2543 const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
2543 const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
25442544 \\const std = @import("std");
25452545 \\export fn foo() void {
25462546 \\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
......@@ -2549,7 +2549,7 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
25492549 \\}
25502550 });
25512551
2552 const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
2552 const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
25532553 \\const std = @import("std");
25542554 \\extern fn foo() void;
25552555 \\pub fn main() void {
......@@ -2797,7 +2797,7 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
27972797 ,
27982798 });
27992799 obj2.root_module.link_libcpp = true;
2800 const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
2800 const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
28012801 \\#include <iostream>
28022802 \\#include <stdexcept>
28032803 \\extern int try_again();
......@@ -2909,7 +2909,7 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
29092909fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {
29102910 const test_step = addTestStep(b, "relocatable-merge-strings", opts);
29112911
2912 const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
2912 const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
29132913 \\.section .rodata.str1.1,"aMS",@progbits,1
29142914 \\val1:
29152915 \\.ascii "Hello \0"
......@@ -3075,7 +3075,7 @@ fn testStrip(b: *Build, opts: Options) *Step {
30753075fn testThunks(b: *Build, opts: Options) *Step {
30763076 const test_step = addTestStep(b, "thunks", opts);
30773077
3078 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
3078 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
30793079 \\void foo();
30803080 \\__attribute__((section(".bar"))) void bar() {
30813081 \\ return foo();
test/link/macho.zig+78-78
......@@ -111,7 +111,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
111111fn testDeadStrip(b: *Build, opts: Options) *Step {
112112 const test_step = addTestStep(b, "dead-strip", opts);
113113
114 const obj = addObject(b, opts, .{ .name = "a", .cpp_source_bytes =
114 const obj = addObject(b, opts, .{ .name = "a", .cpp_source_bytes =
115115 \\#include <stdio.h>
116116 \\int two() { return 2; }
117117 \\int live_var1 = 1;
......@@ -192,13 +192,13 @@ fn testDeadStrip(b: *Build, opts: Options) *Step {
192192fn testDuplicateDefinitions(b: *Build, opts: Options) *Step {
193193 const test_step = addTestStep(b, "duplicate-definitions", opts);
194194
195 const obj = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
195 const obj = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
196196 \\var x: usize = 1;
197197 \\export fn strong() void { x += 1; }
198198 \\export fn weak() void { x += 1; }
199199 });
200200
201 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
201 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
202202 \\var x: usize = 1;
203203 \\export fn strong() void { x += 1; }
204204 \\comptime { @export(&weakImpl, .{ .name = "weak", .linkage = .weak }); }
......@@ -223,7 +223,7 @@ fn testDuplicateDefinitions(b: *Build, opts: Options) *Step {
223223fn testDeadStripDylibs(b: *Build, opts: Options) *Step {
224224 const test_step = addTestStep(b, "dead-strip-dylibs", opts);
225225
226 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
226 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
227227 \\#include <objc/runtime.h>
228228 \\int main() {
229229 \\ if (objc_getClass("NSObject") == 0) {
......@@ -272,7 +272,7 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step {
272272fn testDylib(b: *Build, opts: Options) *Step {
273273 const test_step = addTestStep(b, "dylib", opts);
274274
275 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
275 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
276276 \\#include<stdio.h>
277277 \\char world[] = "world";
278278 \\char* hello() {
......@@ -286,7 +286,7 @@ fn testDylib(b: *Build, opts: Options) *Step {
286286 check.checkNotPresent("PIE");
287287 test_step.dependOn(&check.step);
288288
289 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
289 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
290290 \\#include<stdio.h>
291291 \\char* hello();
292292 \\extern char world[];
......@@ -347,7 +347,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {
347347
348348 const empty = addObject(b, opts, .{ .name = "empty", .c_source_bytes = "" });
349349
350 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
350 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
351351 \\#include <stdio.h>
352352 \\int main() {
353353 \\ printf("Hello world!");
......@@ -377,7 +377,7 @@ fn testEmptyZig(b: *Build, opts: Options) *Step {
377377fn testEntryPoint(b: *Build, opts: Options) *Step {
378378 const test_step = addTestStep(b, "entry-point", opts);
379379
380 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
380 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
381381 \\#include<stdio.h>
382382 \\int non_main() {
383383 \\ printf("%d", 42);
......@@ -599,7 +599,7 @@ fn testHeaderpad(b: *Build, opts: Options) *Step {
599599fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
600600 const test_step = addTestStep(b, "header-weak-flags", opts);
601601
602 const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
602 const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
603603 \\.globl _x
604604 \\.weak_definition _x
605605 \\_x:
......@@ -661,7 +661,7 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
661661 }
662662
663663 {
664 const exe = addExecutable(b, opts, .{ .name = "main3", .asm_source_bytes =
664 const exe = addExecutable(b, opts, .{ .name = "main3", .asm_source_bytes =
665665 \\.globl _main, _x
666666 \\_x:
667667 \\
......@@ -686,7 +686,7 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
686686fn testHelloC(b: *Build, opts: Options) *Step {
687687 const test_step = addTestStep(b, "hello-c", opts);
688688
689 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
689 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
690690 \\#include <stdio.h>
691691 \\int main() {
692692 \\ printf("Hello world!\n");
......@@ -710,7 +710,7 @@ fn testHelloC(b: *Build, opts: Options) *Step {
710710fn testHelloZig(b: *Build, opts: Options) *Step {
711711 const test_step = addTestStep(b, "hello-zig", opts);
712712
713 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
713 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
714714 \\const std = @import("std");
715715 \\pub fn main() void {
716716 \\ std.fs.File.stdout().writeAll("Hello world!\n") catch @panic("fail");
......@@ -731,7 +731,7 @@ fn testLargeBss(b: *Build, opts: Options) *Step {
731731 // linker I tried misbehave in different ways. This only happened on arm64. I thought that
732732 // maybe S_GB_ZEROFILL section is an answer to this but it doesn't seem supported by dyld
733733 // anymore. When I get some free time I will re-investigate this.
734 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
734 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
735735 \\char arr[0x1000000];
736736 \\int main() {
737737 \\ return arr[2000];
......@@ -748,7 +748,7 @@ fn testLargeBss(b: *Build, opts: Options) *Step {
748748fn testLayout(b: *Build, opts: Options) *Step {
749749 const test_step = addTestStep(b, "layout", opts);
750750
751 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
751 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
752752 \\#include <stdio.h>
753753 \\int main() {
754754 \\ printf("Hello world!");
......@@ -938,7 +938,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
938938fn testLinksection(b: *Build, opts: Options) *Step {
939939 const test_step = addTestStep(b, "linksection", opts);
940940
941 const obj = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
941 const obj = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
942942 \\export var test_global: u32 linksection("__DATA,__TestGlobal") = undefined;
943943 \\export fn testFn() linksection("__TEXT,__TestFn") callconv(.c) void {
944944 \\ TestGenericFn("A").f();
......@@ -969,7 +969,7 @@ fn testLinksection(b: *Build, opts: Options) *Step {
969969fn testMergeLiteralsX64(b: *Build, opts: Options) *Step {
970970 const test_step = addTestStep(b, "merge-literals-x64", opts);
971971
972 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
972 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
973973 \\.globl _q1
974974 \\.globl _s1
975975 \\
......@@ -994,7 +994,7 @@ fn testMergeLiteralsX64(b: *Build, opts: Options) *Step {
994994 \\ .quad l._s1
995995 });
996996
997 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
997 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
998998 \\.globl _q2
999999 \\.globl _s2
10001000 \\.globl _s3
......@@ -1024,7 +1024,7 @@ fn testMergeLiteralsX64(b: *Build, opts: Options) *Step {
10241024 \\ .quad l._s3
10251025 });
10261026
1027 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1027 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
10281028 \\#include <stdio.h>
10291029 \\extern double q1();
10301030 \\extern double q2();
......@@ -1085,7 +1085,7 @@ fn testMergeLiteralsX64(b: *Build, opts: Options) *Step {
10851085fn testMergeLiteralsArm64(b: *Build, opts: Options) *Step {
10861086 const test_step = addTestStep(b, "merge-literals-arm64", opts);
10871087
1088 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
1088 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
10891089 \\.globl _q1
10901090 \\.globl _s1
10911091 \\
......@@ -1110,7 +1110,7 @@ fn testMergeLiteralsArm64(b: *Build, opts: Options) *Step {
11101110 \\ .quad l._s1
11111111 });
11121112
1113 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
1113 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
11141114 \\.globl _q2
11151115 \\.globl _s2
11161116 \\.globl _s3
......@@ -1140,7 +1140,7 @@ fn testMergeLiteralsArm64(b: *Build, opts: Options) *Step {
11401140 \\ .quad l._s3
11411141 });
11421142
1143 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1143 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
11441144 \\#include <stdio.h>
11451145 \\extern double q1();
11461146 \\extern double q2();
......@@ -1205,7 +1205,7 @@ fn testMergeLiteralsArm64(b: *Build, opts: Options) *Step {
12051205fn testMergeLiteralsArm642(b: *Build, opts: Options) *Step {
12061206 const test_step = addTestStep(b, "merge-literals-arm64-2", opts);
12071207
1208 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
1208 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
12091209 \\.globl _q1
12101210 \\.globl _s1
12111211 \\
......@@ -1225,7 +1225,7 @@ fn testMergeLiteralsArm642(b: *Build, opts: Options) *Step {
12251225 \\ .double 1.2345
12261226 });
12271227
1228 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
1228 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
12291229 \\.globl _q2
12301230 \\.globl _s2
12311231 \\.globl _s3
......@@ -1248,7 +1248,7 @@ fn testMergeLiteralsArm642(b: *Build, opts: Options) *Step {
12481248 \\ .double 1.2345
12491249 });
12501250
1251 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1251 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
12521252 \\#include <stdio.h>
12531253 \\extern double q1();
12541254 \\extern double q2();
......@@ -1279,7 +1279,7 @@ fn testMergeLiteralsArm642(b: *Build, opts: Options) *Step {
12791279fn testMergeLiteralsAlignment(b: *Build, opts: Options) *Step {
12801280 const test_step = addTestStep(b, "merge-literals-alignment", opts);
12811281
1282 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
1282 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
12831283 \\.globl _s1
12841284 \\.globl _s2
12851285 \\
......@@ -1291,7 +1291,7 @@ fn testMergeLiteralsAlignment(b: *Build, opts: Options) *Step {
12911291 \\ .asciz "str2"
12921292 });
12931293
1294 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
1294 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
12951295 \\.globl _s3
12961296 \\.globl _s4
12971297 \\
......@@ -1303,7 +1303,7 @@ fn testMergeLiteralsAlignment(b: *Build, opts: Options) *Step {
13031303 \\ .asciz "str2"
13041304 });
13051305
1306 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1306 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
13071307 \\#include <assert.h>
13081308 \\#include <stdint.h>
13091309 \\#include <stdio.h>
......@@ -1358,7 +1358,7 @@ fn testMergeLiteralsAlignment(b: *Build, opts: Options) *Step {
13581358fn testMergeLiteralsObjc(b: *Build, opts: Options) *Step {
13591359 const test_step = addTestStep(b, "merge-literals-objc", opts);
13601360
1361 const main_o = addObject(b, opts, .{ .name = "main", .objc_source_bytes =
1361 const main_o = addObject(b, opts, .{ .name = "main", .objc_source_bytes =
13621362 \\#import <Foundation/Foundation.h>;
13631363 \\
13641364 \\extern void foo();
......@@ -1376,7 +1376,7 @@ fn testMergeLiteralsObjc(b: *Build, opts: Options) *Step {
13761376 \\}
13771377 });
13781378
1379 const a_o = addObject(b, opts, .{ .name = "a", .objc_source_bytes =
1379 const a_o = addObject(b, opts, .{ .name = "a", .objc_source_bytes =
13801380 \\#import <Foundation/Foundation.h>;
13811381 \\
13821382 \\void foo() {
......@@ -1461,7 +1461,7 @@ fn testMhExecuteHeader(b: *Build, opts: Options) *Step {
14611461fn testNoDeadStrip(b: *Build, opts: Options) *Step {
14621462 const test_step = addTestStep(b, "no-dead-strip", opts);
14631463
1464 const exe = addExecutable(b, opts, .{ .name = "name", .c_source_bytes =
1464 const exe = addExecutable(b, opts, .{ .name = "name", .c_source_bytes =
14651465 \\__attribute__((used)) int bogus1 = 0;
14661466 \\int bogus2 = 0;
14671467 \\int foo = 42;
......@@ -1545,7 +1545,7 @@ fn testNeededLibrary(b: *Build, opts: Options) *Step {
15451545fn testObjc(b: *Build, opts: Options) *Step {
15461546 const test_step = addTestStep(b, "objc", opts);
15471547
1548 const lib = addStaticLibrary(b, opts, .{ .name = "a", .objc_source_bytes =
1548 const lib = addStaticLibrary(b, opts, .{ .name = "a", .objc_source_bytes =
15491549 \\#import <Foundation/Foundation.h>
15501550 \\@interface Foo : NSObject
15511551 \\@end
......@@ -1602,7 +1602,7 @@ fn testObjcpp(b: *Build, opts: Options) *Step {
16021602 );
16031603 };
16041604
1605 const foo_o = addObject(b, opts, .{ .name = "foo", .objcpp_source_bytes =
1605 const foo_o = addObject(b, opts, .{ .name = "foo", .objcpp_source_bytes =
16061606 \\#import "Foo.h"
16071607 \\@implementation Foo
16081608 \\- (NSString *)name
......@@ -1615,7 +1615,7 @@ fn testObjcpp(b: *Build, opts: Options) *Step {
16151615 foo_o.root_module.addIncludePath(foo_h.dirname());
16161616 foo_o.root_module.link_libcpp = true;
16171617
1618 const exe = addExecutable(b, opts, .{ .name = "main", .objcpp_source_bytes =
1618 const exe = addExecutable(b, opts, .{ .name = "main", .objcpp_source_bytes =
16191619 \\#import "Foo.h"
16201620 \\#import <assert.h>
16211621 \\#include <iostream>
......@@ -1679,7 +1679,7 @@ fn testPagezeroSize(b: *Build, opts: Options) *Step {
16791679fn testReexportsZig(b: *Build, opts: Options) *Step {
16801680 const test_step = addTestStep(b, "reexports-zig", opts);
16811681
1682 const lib = addStaticLibrary(b, opts, .{ .name = "a", .zig_source_bytes =
1682 const lib = addStaticLibrary(b, opts, .{ .name = "a", .zig_source_bytes =
16831683 \\const x: i32 = 42;
16841684 \\export fn foo() i32 {
16851685 \\ return x;
......@@ -1689,7 +1689,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {
16891689 \\}
16901690 });
16911691
1692 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
1692 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
16931693 \\extern int foo();
16941694 \\extern int bar();
16951695 \\int main() {
......@@ -1708,7 +1708,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {
17081708fn testRelocatable(b: *Build, opts: Options) *Step {
17091709 const test_step = addTestStep(b, "relocatable", opts);
17101710
1711 const a_o = addObject(b, opts, .{ .name = "a", .cpp_source_bytes =
1711 const a_o = addObject(b, opts, .{ .name = "a", .cpp_source_bytes =
17121712 \\#include <stdexcept>
17131713 \\int try_me() {
17141714 \\ throw std::runtime_error("Oh no!");
......@@ -1716,14 +1716,14 @@ fn testRelocatable(b: *Build, opts: Options) *Step {
17161716 });
17171717 a_o.root_module.link_libcpp = true;
17181718
1719 const b_o = addObject(b, opts, .{ .name = "b", .cpp_source_bytes =
1719 const b_o = addObject(b, opts, .{ .name = "b", .cpp_source_bytes =
17201720 \\extern int try_me();
17211721 \\int try_again() {
17221722 \\ return try_me();
17231723 \\}
17241724 });
17251725
1726 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
1726 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
17271727 \\#include <iostream>
17281728 \\#include <stdexcept>
17291729 \\extern int try_again();
......@@ -1776,7 +1776,7 @@ fn testRelocatable(b: *Build, opts: Options) *Step {
17761776fn testRelocatableZig(b: *Build, opts: Options) *Step {
17771777 const test_step = addTestStep(b, "relocatable-zig", opts);
17781778
1779 const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
1779 const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
17801780 \\const std = @import("std");
17811781 \\export var foo: i32 = 0;
17821782 \\export fn incrFoo() void {
......@@ -1785,7 +1785,7 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {
17851785 \\}
17861786 });
17871787
1788 const b_o = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
1788 const b_o = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
17891789 \\const std = @import("std");
17901790 \\extern var foo: i32;
17911791 \\export fn decrFoo() void {
......@@ -1794,7 +1794,7 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {
17941794 \\}
17951795 });
17961796
1797 const main_o = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
1797 const main_o = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
17981798 \\const std = @import("std");
17991799 \\extern var foo: i32;
18001800 \\extern fn incrFoo() void;
......@@ -1827,7 +1827,7 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {
18271827fn testSearchStrategy(b: *Build, opts: Options) *Step {
18281828 const test_step = addTestStep(b, "search-strategy", opts);
18291829
1830 const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes =
1830 const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes =
18311831 \\#include<stdio.h>
18321832 \\char world[] = "world";
18331833 \\char* hello() {
......@@ -1841,7 +1841,7 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {
18411841 const dylib = addSharedLibrary(b, opts, .{ .name = "a" });
18421842 dylib.root_module.addObject(obj);
18431843
1844 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1844 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
18451845 \\#include<stdio.h>
18461846 \\char* hello();
18471847 \\extern char world[];
......@@ -1975,7 +1975,7 @@ fn testSectionBoundarySymbols(b: *Build, opts: Options) *Step {
19751975fn testSectionBoundarySymbols2(b: *Build, opts: Options) *Step {
19761976 const test_step = addTestStep(b, "section-boundary-symbols-2", opts);
19771977
1978 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
1978 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
19791979 \\#include <stdio.h>
19801980 \\struct pair { int a; int b; };
19811981 \\struct pair first __attribute__((section("__DATA,__pairs"))) = { 1, 2 };
......@@ -2012,11 +2012,11 @@ fn testSectionBoundarySymbols2(b: *Build, opts: Options) *Step {
20122012fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
20132013 const test_step = addTestStep(b, "segment-boundary-symbols", opts);
20142014
2015 const obj1 = addObject(b, opts, .{ .name = "a", .cpp_source_bytes =
2015 const obj1 = addObject(b, opts, .{ .name = "a", .cpp_source_bytes =
20162016 \\constexpr const char* MESSAGE __attribute__((used, section("__DATA_CONST_1,__message_ptr"))) = "codebase";
20172017 });
20182018
2019 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
2019 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
20202020 \\#include <stdio.h>
20212021 \\const char* interop();
20222022 \\int main() {
......@@ -2026,7 +2026,7 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
20262026 });
20272027
20282028 {
2029 const obj2 = addObject(b, opts, .{ .name = "b", .cpp_source_bytes =
2029 const obj2 = addObject(b, opts, .{ .name = "b", .cpp_source_bytes =
20302030 \\extern const char* message_pointer __asm("segment$start$__DATA_CONST_1");
20312031 \\extern "C" const char* interop() {
20322032 \\ return message_pointer;
......@@ -2049,7 +2049,7 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
20492049 }
20502050
20512051 {
2052 const obj2 = addObject(b, opts, .{ .name = "c", .cpp_source_bytes =
2052 const obj2 = addObject(b, opts, .{ .name = "c", .cpp_source_bytes =
20532053 \\extern const char* message_pointer __asm("segment$start$__DATA_1");
20542054 \\extern "C" const char* interop() {
20552055 \\ return message_pointer;
......@@ -2080,21 +2080,21 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
20802080fn testSymbolStabs(b: *Build, opts: Options) *Step {
20812081 const test_step = addTestStep(b, "symbol-stabs", opts);
20822082
2083 const a_o = addObject(b, opts, .{ .name = "a", .c_source_bytes =
2083 const a_o = addObject(b, opts, .{ .name = "a", .c_source_bytes =
20842084 \\int foo = 42;
20852085 \\int getFoo() {
20862086 \\ return foo;
20872087 \\}
20882088 });
20892089
2090 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
2090 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
20912091 \\int bar = 24;
20922092 \\int getBar() {
20932093 \\ return bar;
20942094 \\}
20952095 });
20962096
2097 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
2097 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
20982098 \\#include <stdio.h>
20992099 \\extern int getFoo();
21002100 \\extern int getBar();
......@@ -2164,7 +2164,7 @@ fn testTbdv3(b: *Build, opts: Options) *Step {
21642164 );
21652165 };
21662166
2167 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2167 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
21682168 \\#include <stdio.h>
21692169 \\int getFoo();
21702170 \\int main() {
......@@ -2211,7 +2211,7 @@ fn testTentative(b: *Build, opts: Options) *Step {
22112211fn testThunks(b: *Build, opts: Options) *Step {
22122212 const test_step = addTestStep(b, "thunks", opts);
22132213
2214 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2214 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
22152215 \\#include <stdio.h>
22162216 \\void bar() {
22172217 \\ printf("bar");
......@@ -2243,14 +2243,14 @@ fn testThunks(b: *Build, opts: Options) *Step {
22432243fn testTls(b: *Build, opts: Options) *Step {
22442244 const test_step = addTestStep(b, "tls", opts);
22452245
2246 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
2246 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
22472247 \\_Thread_local int a;
22482248 \\int getA() {
22492249 \\ return a;
22502250 \\}
22512251 });
22522252
2253 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2253 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
22542254 \\#include<stdio.h>
22552255 \\extern _Thread_local int a;
22562256 \\extern int getA();
......@@ -2294,7 +2294,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
22942294 );
22952295 };
22962296
2297 const bar_o = addObject(b, opts, .{ .name = "bar", .cpp_source_bytes =
2297 const bar_o = addObject(b, opts, .{ .name = "bar", .cpp_source_bytes =
22982298 \\#include "foo.h"
22992299 \\int bar() {
23002300 \\ int v1 = Foo<int>::getVar();
......@@ -2304,7 +2304,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
23042304 bar_o.root_module.addIncludePath(foo_h.dirname());
23052305 bar_o.root_module.link_libcpp = true;
23062306
2307 const baz_o = addObject(b, opts, .{ .name = "baz", .cpp_source_bytes =
2307 const baz_o = addObject(b, opts, .{ .name = "baz", .cpp_source_bytes =
23082308 \\#include "foo.h"
23092309 \\int baz() {
23102310 \\ int v1 = Foo<unsigned>::getVar();
......@@ -2314,7 +2314,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
23142314 baz_o.root_module.addIncludePath(foo_h.dirname());
23152315 baz_o.root_module.link_libcpp = true;
23162316
2317 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
2317 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
23182318 \\extern int bar();
23192319 \\extern int baz();
23202320 \\int main() {
......@@ -2342,7 +2342,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
23422342fn testTlsLargeTbss(b: *Build, opts: Options) *Step {
23432343 const test_step = addTestStep(b, "tls-large-tbss", opts);
23442344
2345 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2345 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
23462346 \\#include <stdio.h>
23472347 \\_Thread_local int x[0x8000];
23482348 \\_Thread_local int y[0x8000];
......@@ -2363,7 +2363,7 @@ fn testTlsLargeTbss(b: *Build, opts: Options) *Step {
23632363fn testTlsZig(b: *Build, opts: Options) *Step {
23642364 const test_step = addTestStep(b, "tls-zig", opts);
23652365
2366 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
2366 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
23672367 \\const std = @import("std");
23682368 \\threadlocal var x: i32 = 0;
23692369 \\threadlocal var y: i32 = -1;
......@@ -2390,7 +2390,7 @@ fn testTlsZig(b: *Build, opts: Options) *Step {
23902390fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
23912391 const test_step = addTestStep(b, "two-level-namespace", opts);
23922392
2393 const liba = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
2393 const liba = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
23942394 \\#include <stdio.h>
23952395 \\int foo = 1;
23962396 \\int* ptr_to_foo = &foo;
......@@ -2411,7 +2411,7 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
24112411 test_step.dependOn(&check.step);
24122412 }
24132413
2414 const libb = addSharedLibrary(b, opts, .{ .name = "b", .c_source_bytes =
2414 const libb = addSharedLibrary(b, opts, .{ .name = "b", .c_source_bytes =
24152415 \\#include <stdio.h>
24162416 \\int foo = 2;
24172417 \\int* ptr_to_foo = &foo;
......@@ -2432,7 +2432,7 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
24322432 test_step.dependOn(&check.step);
24332433 }
24342434
2435 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
2435 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
24362436 \\#include <stdio.h>
24372437 \\int getFoo();
24382438 \\extern int* ptr_to_foo;
......@@ -2632,12 +2632,12 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
26322632fn testUnresolvedError(b: *Build, opts: Options) *Step {
26332633 const test_step = addTestStep(b, "unresolved-error", opts);
26342634
2635 const obj = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
2635 const obj = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
26362636 \\extern fn foo() i32;
26372637 \\export fn bar() i32 { return foo() + 1; }
26382638 });
26392639
2640 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
2640 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
26412641 \\const std = @import("std");
26422642 \\extern fn foo() i32;
26432643 \\extern fn bar() i32;
......@@ -2668,7 +2668,7 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {
26682668fn testUnresolvedError2(b: *Build, opts: Options) *Step {
26692669 const test_step = addTestStep(b, "unresolved-error-2", opts);
26702670
2671 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
2671 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
26722672 \\pub fn main() !void {
26732673 \\ const msg_send_fn = @extern(
26742674 \\ *const fn () callconv(.c) usize,
......@@ -2740,7 +2740,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
27402740 );
27412741 };
27422742
2743 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
2743 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
27442744 \\#include "all.h"
27452745 \\#include <cstdio>
27462746 \\
......@@ -2769,7 +2769,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
27692769 main_o.root_module.addIncludePath(all_h.dirname());
27702770 main_o.root_module.link_libcpp = true;
27712771
2772 const simple_string_o = addObject(b, opts, .{ .name = "simple_string", .cpp_source_bytes =
2772 const simple_string_o = addObject(b, opts, .{ .name = "simple_string", .cpp_source_bytes =
27732773 \\#include "all.h"
27742774 \\#include <cstdio>
27752775 \\#include <cstring>
......@@ -2804,7 +2804,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
28042804 simple_string_o.root_module.addIncludePath(all_h.dirname());
28052805 simple_string_o.root_module.link_libcpp = true;
28062806
2807 const simple_string_owner_o = addObject(b, opts, .{ .name = "simple_string_owner", .cpp_source_bytes =
2807 const simple_string_owner_o = addObject(b, opts, .{ .name = "simple_string_owner", .cpp_source_bytes =
28082808 \\#include "all.h"
28092809 \\
28102810 \\SimpleStringOwner::SimpleStringOwner(const char* x) : string{ 10 } {
......@@ -2851,7 +2851,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
28512851fn testUnwindInfoNoSubsectionsArm64(b: *Build, opts: Options) *Step {
28522852 const test_step = addTestStep(b, "unwind-info-no-subsections-arm64", opts);
28532853
2854 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
2854 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
28552855 \\.globl _foo
28562856 \\.align 4
28572857 \\_foo:
......@@ -2891,7 +2891,7 @@ fn testUnwindInfoNoSubsectionsArm64(b: *Build, opts: Options) *Step {
28912891 \\ .cfi_endproc
28922892 });
28932893
2894 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2894 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
28952895 \\#include <stdio.h>
28962896 \\int foo();
28972897 \\int main() {
......@@ -2911,7 +2911,7 @@ fn testUnwindInfoNoSubsectionsArm64(b: *Build, opts: Options) *Step {
29112911fn testUnwindInfoNoSubsectionsX64(b: *Build, opts: Options) *Step {
29122912 const test_step = addTestStep(b, "unwind-info-no-subsections-x64", opts);
29132913
2914 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
2914 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
29152915 \\.globl _foo
29162916 \\_foo:
29172917 \\ .cfi_startproc
......@@ -2943,7 +2943,7 @@ fn testUnwindInfoNoSubsectionsX64(b: *Build, opts: Options) *Step {
29432943 \\ .cfi_endproc
29442944 });
29452945
2946 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2946 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
29472947 \\#include <stdio.h>
29482948 \\int foo();
29492949 \\int main() {
......@@ -2964,7 +2964,7 @@ fn testUnwindInfoNoSubsectionsX64(b: *Build, opts: Options) *Step {
29642964fn testWeakBind(b: *Build, opts: Options) *Step {
29652965 const test_step = addTestStep(b, "weak-bind", opts);
29662966
2967 const lib = addSharedLibrary(b, opts, .{ .name = "foo", .asm_source_bytes =
2967 const lib = addSharedLibrary(b, opts, .{ .name = "foo", .asm_source_bytes =
29682968 \\.globl _weak_dysym
29692969 \\.weak_definition _weak_dysym
29702970 \\_weak_dysym:
......@@ -2998,7 +2998,7 @@ fn testWeakBind(b: *Build, opts: Options) *Step {
29982998 test_step.dependOn(&check.step);
29992999 }
30003000
3001 const exe = addExecutable(b, opts, .{ .name = "main", .asm_source_bytes =
3001 const exe = addExecutable(b, opts, .{ .name = "main", .asm_source_bytes =
30023002 \\.globl _main, _weak_external, _weak_external_for_gotpcrel, _weak_external_fn
30033003 \\.weak_definition _weak_external, _weak_external_for_gotpcrel, _weak_external_fn, _weak_internal, _weak_internal_for_gotpcrel, _weak_internal_fn
30043004 \\
......@@ -3114,7 +3114,7 @@ fn testWeakFramework(b: *Build, opts: Options) *Step {
31143114fn testWeakLibrary(b: *Build, opts: Options) *Step {
31153115 const test_step = addTestStep(b, "weak-library", opts);
31163116
3117 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
3117 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
31183118 \\#include<stdio.h>
31193119 \\int a = 42;
31203120 \\const char* asStr() {
......@@ -3124,7 +3124,7 @@ fn testWeakLibrary(b: *Build, opts: Options) *Step {
31243124 \\}
31253125 });
31263126
3127 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
3127 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
31283128 \\#include<stdio.h>
31293129 \\extern int a;
31303130 \\extern const char* asStr();
......@@ -3157,7 +3157,7 @@ fn testWeakLibrary(b: *Build, opts: Options) *Step {
31573157fn testWeakRef(b: *Build, opts: Options) *Step {
31583158 const test_step = addTestStep(b, "weak-ref", opts);
31593159
3160 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
3160 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
31613161 \\#include <stdio.h>
31623162 \\#include <sys/_types/_fd_def.h>
31633163 \\int main(int argc, char** argv) {