[PATCH] ubsan: Port runtime library to (32- and 64-bit) Windows.

Peter Collingbourne peter at pcc.me.uk
Tue Jun 30 21:33:13 PDT 2015


================
Comment at: lib/ubsan/ubsan_diag.cc:189
@@ -188,1 +188,3 @@
         char Buffer[32];
+#if defined(_WIN32)
+        sprintf_s(Buffer, sizeof(Buffer), "%Lg", (long double)A.Float);
----------------
samsonov wrote:
> SANITIZER_WINDOWS
Done

================
Comment at: lib/ubsan/ubsan_flags.cc:75
@@ +74,3 @@
+#if SANITIZER_WINDOWS
+const char *__ubsan_default_default_options() { return ""; }
+#pragma comment(linker, "/alternatename:__ubsan_default_options=__ubsan_default_default_options")
----------------
rnk wrote:
> samsonov wrote:
> > What does this function mean?
> Peter, at some point we might implement attribute weak in clang the way mingw does, where we automatically create a new symbol and a weak alias to it with the original name, so you might want to make this `#elif SANITIZER_WINDOWS`.
Did you misread line 69 of the new code as `#if SANITIZER_SUPPORTS_WEAK_HOOKS`? I think `SANITIZER_SUPPORTS_WEAK_HOOKS` means "do the sanitizers support hooks (either through attribute weak or `/alternatename`)" rather than "does the compiler support attribute weak". This does seem a little silly, but I was trying to be consistent with the stuff in `lib/asan/asan_win.cc`.

================
Comment at: lib/ubsan/ubsan_platform.h:20
@@ -20,1 +19,3 @@
+     defined(__aarch64__) || defined(__mips__) || defined(__powerpc64__)) || \
+     defined(_WIN32)
 # define CAN_SANITIZE_UB 1
----------------
samsonov wrote:
> Group OS together. Also, consider #including `sanitizer_platform.h` and using SANITIZER_LINUX, SANITIZER_WINDOWS etc.
> Group OS together.

Won't work, at least with cl.exe; that compiler does not define the architecture macros.

http://reviews.llvm.org/D10856

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list