[llvm-bugs] [Bug 35030] New: clang-format does weird things to comment indentation in __asm blocks
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Oct 22 14:17:22 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=35030
Bug ID: 35030
Summary: clang-format does weird things to comment indentation
in __asm blocks
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: nicolasweber at gmx.de
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171022/5fad56aa/attachment.html>
More information about the llvm-bugs
mailing list