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: unassignedclangb...@nondot.org
Reporter: nicolaswe...@gmx.de
CC: djas...@google.com, kli...@google.com,
llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs