authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-05-13 11:22:42+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-13 12:20:11-04:00
log08d41da916787ab0c19130dc4dc4e7b0e75c9fa8
treebd54f4198e37b5baf708375632fb8419fd2d52c8
parent66d86eccbe43e01500bd57dba13a4ce68aba8921

Fix formatting for multiline asm expressions


3 files changed, 51 insertions(+), 3 deletions(-)

std/valgrind.zig+2-2
......@@ -12,7 +12,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
1212 \\ roll $3, %%edi ; roll $13, %%edi
1313 \\ roll $29, %%edi ; roll $19, %%edi
1414 \\ xchgl %%ebx,%%ebx
15 : [_] "={edx}" (-> usize)
15 : [_] "={edx}" (-> usize)
1616 : [_] "{eax}" (&[]usize{ request, a1, a2, a3, a4, a5 }),
1717 [_] "0" (default)
1818 : "cc", "memory"
......@@ -23,7 +23,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
2323 \\ rolq $3, %%rdi ; rolq $13, %%rdi
2424 \\ rolq $61, %%rdi ; rolq $51, %%rdi
2525 \\ xchgq %%rbx,%%rbx
26 : [_] "={rdx}" (-> usize)
26 : [_] "={rdx}" (-> usize)
2727 : [_] "{rax}" (&[]usize{ request, a1, a2, a3, a4, a5 }),
2828 [_] "0" (default)
2929 : "cc", "memory"
std/zig/parser_test.zig+41
......@@ -2129,6 +2129,47 @@ test "zig fmt: comptime block in container" {
21292129 );
21302130}
21312131
2132test "zig fmt: inline asm parameter alignment" {
2133 try testCanonical(
2134 \\pub fn main() void {
2135 \\ asm volatile (
2136 \\ \\ foo
2137 \\ \\ bar
2138 \\ );
2139 \\ asm volatile (
2140 \\ \\ foo
2141 \\ \\ bar
2142 \\ : [_] "" (-> usize),
2143 \\ [_] "" (-> usize)
2144 \\ );
2145 \\ asm volatile (
2146 \\ \\ foo
2147 \\ \\ bar
2148 \\ :
2149 \\ : [_] "" (0),
2150 \\ [_] "" (0)
2151 \\ );
2152 \\ asm volatile (
2153 \\ \\ foo
2154 \\ \\ bar
2155 \\ :
2156 \\ :
2157 \\ : "", ""
2158 \\ );
2159 \\ asm volatile (
2160 \\ \\ foo
2161 \\ \\ bar
2162 \\ : [_] "" (-> usize),
2163 \\ [_] "" (-> usize)
2164 \\ : [_] "" (0),
2165 \\ [_] "" (0)
2166 \\ : "", ""
2167 \\ );
2168 \\}
2169 \\
2170 );
2171}
2172
21322173const std = @import("std");
21332174const mem = std.mem;
21342175const warn = std.debug.warn;
std/zig/render.zig+8-1
......@@ -1549,7 +1549,14 @@ fn renderExpression(
15491549 try renderExpression(allocator, stream, tree, indent, start_col, asm_node.template, Space.Newline);
15501550
15511551 const indent_once = indent + indent_delta;
1552 try stream.writeByteNTimes(' ', indent_once);
1552
1553 if (asm_node.template.id == ast.Node.Id.MultilineStringLiteral) {
1554 // After rendering a multiline string literal the cursor is
1555 // already offset by indent
1556 try stream.writeByteNTimes(' ', indent_delta);
1557 } else {
1558 try stream.writeByteNTimes(' ', indent_once);
1559 }
15531560
15541561 const colon1 = tree.nextToken(asm_node.template.lastToken());
15551562 const indent_extra = indent_once + 2;