<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-format does weird things to comment indentation in __asm blocks"
href="https://bugs.llvm.org/show_bug.cgi?id=35030">35030</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-format does weird things to comment indentation in __asm blocks
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>In:
__declspec(naked) bool SafeTerminateProcess(HANDLE process, UINT exit_code) {
__asm {
push ebp
mov ebp, esp
push [ebp+12]
push [ebp+8]
call TerminateProcess
// Convert from BOOL to bool.
test eax, eax
setne al
// TerminateProcess() is supposed to be stdcall (callee clean-up), and esp
// and ebp are expected to already be equal. But if it’s been patched badly
// by something that’s cdecl (caller clean-up), this next move will get
// things back on track.
mov esp, ebp
pop ebp
ret
}
}
Out:
// This function is written in assembler source because it’s important for it
// to not be inlined, for it to allocate a stack frame, and most critically,
// for it to not trust esp on return from TerminateProcess().
// __declspec(naked) conveniently prevents inlining and allows us to control
// stack layout.
__declspec(naked) bool SafeTerminateProcess(HANDLE process, UINT exit_code) {
__asm {
push ebp
mov ebp, esp
push [ebp+12]
push [ebp+8]
call TerminateProcess
// Convert from BOOL to bool.
test eax, eax
setne al
// TerminateProcess() is supposed to be stdcall (callee clean-up), and
// esp and ebp are expected to already be equal. But if it’s been
// patched badly by something that’s cdecl (caller clean-up), this next
// move will get things back on track.
mov esp, ebp
pop ebp
ret
}
}
Should just keep the initial version.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>