Skip to content

Commit 1822bc1

Browse files
authored
Remove __cdecl from _ReturnAddress (#72919)
As an intrinsic, `_ReturnAddress` does not need it; additionally, if someone else declares `_ReturnAddress` without `__cdecl` (for example, `<intrin.h>`) Additionally, actually add a test for this change. I've tested it locally with both LLVM and MSVC.
1 parent 3e28e1e commit 1822bc1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

compiler-rt/include/sanitizer/common_interface_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void SANITIZER_CDECL __sanitizer_symbolize_global(void *data_ptr,
293293
#define __sanitizer_return_address() \
294294
__builtin_extract_return_addr(__builtin_return_address(0))
295295
#else
296-
void *SANITIZER_CDECL _ReturnAddress(void);
296+
void *_ReturnAddress(void);
297297
#pragma intrinsic(_ReturnAddress)
298298
#define __sanitizer_return_address() _ReturnAddress()
299299
#endif
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Make sure that ASan works with non-cdecl default calling conventions.
2+
// Many x86 projects pass `/Gz` to their compiles, so that __stdcall is the default,
3+
// but LLVM is built with __cdecl.
4+
//
5+
// RUN: %clang_cl_asan -Gz %Od %s %Fe%t
6+
7+
// includes a declaration of `_ReturnAddress`
8+
#include <intrin.h>
9+
10+
#include <sanitizer/asan_interface.h>
11+
12+
int main() {
13+
alignas(8) char buffer[8];
14+
__asan_poison_memory_region(buffer, sizeof buffer);
15+
}

0 commit comments

Comments
 (0)