[compiler-rt] [compiler-rt][asan] Add wcscpy/wcsncpy; enable wcscat/wcsncat on Windows (PR #160493)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 24 09:24:55 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- compiler-rt/test/asan/TestCases/wcscat.cpp compiler-rt/test/asan/TestCases/wcscpy.cpp compiler-rt/test/asan/TestCases/wcsncat.cpp compiler-rt/test/asan/TestCases/wcsncpy.cpp compiler-rt/lib/asan/asan_interceptors.cpp compiler-rt/lib/asan/asan_interceptors.h compiler-rt/lib/asan/asan_win_static_runtime_thunk.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index 2eb02fe4f..7272b8f41 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -65,12 +65,12 @@ static inline uptr MaybeRealStrnlen(const char *s, uptr maxlen) {
   return internal_strnlen(s, maxlen);
 }
 
-static inline uptr MaybeRealWcsnlen(const wchar_t *s, uptr maxlen) {
-#if SANITIZER_INTERCEPT_WCSNLEN
+static inline uptr MaybeRealWcsnlen(const wchar_t* s, uptr maxlen) {
+#  if SANITIZER_INTERCEPT_WCSNLEN
   if (REAL(wcsnlen)) {
     return REAL(wcsnlen)(s, maxlen);
   }
-#endif
+#  endif
   return internal_wcsnlen(s, maxlen);
 }
 
@@ -579,8 +579,8 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
   return REAL(strcpy)(to, from);
 }
 
-INTERCEPTOR(wchar_t *, wcscpy, wchar_t *to, const wchar_t *from) {
-  void *ctx;
+INTERCEPTOR(wchar_t*, wcscpy, wchar_t* to, const wchar_t* from) {
+  void* ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, wcscpy);
   if (!TryAsanInitFromRtl())
     return REAL(wcscpy)(to, from);
@@ -656,8 +656,8 @@ INTERCEPTOR(char*, strncpy, char *to, const char *from, usize size) {
   return REAL(strncpy)(to, from, size);
 }
 
-INTERCEPTOR(wchar_t *, wcsncpy, wchar_t *to, const wchar_t *from, uptr size) {
-  void *ctx;
+INTERCEPTOR(wchar_t*, wcsncpy, wchar_t* to, const wchar_t* from, uptr size) {
+  void* ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, wcsncpy);
   AsanInitFromRtl();
   if (flags()->replace_str) {
diff --git a/compiler-rt/lib/asan/asan_interceptors.h b/compiler-rt/lib/asan/asan_interceptors.h
index 33d4210b5..2d551cfaf 100644
--- a/compiler-rt/lib/asan/asan_interceptors.h
+++ b/compiler-rt/lib/asan/asan_interceptors.h
@@ -129,7 +129,7 @@ DECLARE_REAL(char*, strchr, const char *str, int c)
 DECLARE_REAL(SIZE_T, strlen, const char *s)
 DECLARE_REAL(char*, strncpy, char *to, const char *from, SIZE_T size)
 DECLARE_REAL(SIZE_T, strnlen, const char *s, SIZE_T maxlen)
-DECLARE_REAL(SIZE_T, wcsnlen, const wchar_t *s, SIZE_T maxlen)
+DECLARE_REAL(SIZE_T, wcsnlen, const wchar_t* s, SIZE_T maxlen)
 DECLARE_REAL(char*, strstr, const char *s1, const char *s2)
 
 #  if !SANITIZER_APPLE

``````````

</details>


https://github.com/llvm/llvm-project/pull/160493


More information about the llvm-commits mailing list