[compiler-rt] r241303 - UBSan: Enable runtime library tests on Windows, and get most tests passing.

Peter Collingbourne peter at pcc.me.uk
Thu Jul 2 15:08:38 PDT 2015


Author: pcc
Date: Thu Jul  2 17:08:38 2015
New Revision: 241303

URL: http://llvm.org/viewvc/llvm-project?rev=241303&view=rev
Log:
UBSan: Enable runtime library tests on Windows, and get most tests passing.

Specifically:

- Disable int128 tests on Windows, as MSVC cl.exe does not support
  int128, so we might not have been able to build the runtime
  with int128 support.

- XFAIL the vptr tests as we lack Microsoft ABI support.

- XFAIL enum.cpp as UBSan fails to add the correct instrumentation code
  for some reason.

- Modify certain tests that build executables multiple times to use
  unique names for each executable. This works around a race condition
  observed on Windows.

- Implement IsAccessibleMemoryRange for Windows to fix the last
  misaligned.cpp test.

- Introduce a substitution for testing crashes on Windows using
  KillTheDoctor.

Differential Revision: http://reviews.llvm.org/D10864

Modified:
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
    compiler-rt/trunk/test/CMakeLists.txt
    compiler-rt/trunk/test/lit.common.cfg
    compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Integer/add-overflow.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Integer/div-zero.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Integer/incdec-overflow.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Integer/negate-overflow.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Integer/sub-overflow.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Integer/uadd-overflow.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Integer/uincdec-overflow.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Integer/usub-overflow.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Misc/deduplication.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp
    compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp
    compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/misaligned.cpp
    compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp
    compiler-rt/trunk/test/ubsan/lit.common.cfg

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Thu Jul  2 17:08:38 2015
@@ -333,6 +333,9 @@ if(APPLE AND SANITIZER_MIN_OSX_VERSION V
   # Mac OS X prior to 10.9 had problems with exporting symbols from
   # libc++/libc++abi.
   set(SANITIZER_CAN_USE_CXXABI FALSE)
+elseif(WIN32)
+  # We do not currently support the Microsoft C++ ABI.
+  set(SANITIZER_CAN_USE_CXXABI FALSE)
 else()
   set(SANITIZER_CAN_USE_CXXABI TRUE)
 endif()

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Thu Jul  2 17:08:38 2015
@@ -35,7 +35,9 @@ namespace __sanitizer {
 
 // --------------------- sanitizer_common.h
 uptr GetPageSize() {
-  return 1U << 14;  // FIXME: is this configurable?
+  // FIXME: there is an API for getting the system page size (GetSystemInfo or
+  // GetNativeSystemInfo), but if we use it here we get test failures elsewhere.
+  return 1U << 14;
 }
 
 uptr GetMmapGranularity() {
@@ -615,7 +617,27 @@ bool IsDeadlySignal(int signum) {
 }
 
 bool IsAccessibleMemoryRange(uptr beg, uptr size) {
-  // FIXME: Actually implement this function.
+  SYSTEM_INFO si;
+  GetNativeSystemInfo(&si);
+  uptr page_size = si.dwPageSize;
+  uptr page_mask = ~(page_size - 1);
+
+  for (uptr page = beg & page_mask, end = (beg + size - 1) & page_mask;
+       page <= end;) {
+    MEMORY_BASIC_INFORMATION info;
+    if (VirtualQuery((LPCVOID)page, &info, sizeof(info)) != sizeof(info))
+      return false;
+
+    if (info.Protect == 0 || info.Protect == PAGE_NOACCESS ||
+        info.Protect == PAGE_EXECUTE)
+      return false;
+
+    if (info.RegionSize == 0)
+      return false;
+
+    page += info.RegionSize;
+  }
+
   return true;
 }
 

Modified: compiler-rt/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/CMakeLists.txt?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/CMakeLists.txt Thu Jul  2 17:08:38 2015
@@ -24,6 +24,9 @@ if(NOT ANDROID)
     if (COMPILER_RT_HAS_PROFILE)
       list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
     endif()
+    if (WIN32)
+      list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
+    endif()
   endif()
   if(UNIX)
     list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS SanitizerLintCheck)

Modified: compiler-rt/trunk/test/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.cfg?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/lit.common.cfg (original)
+++ compiler-rt/trunk/test/lit.common.cfg Thu Jul  2 17:08:38 2015
@@ -80,6 +80,15 @@ config.substitutions.append( ('%run', co
 # Define CHECK-%os to check for OS-dependent output.
 config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))
 
+if config.host_os == 'Windows':
+  # FIXME: This isn't quite right. Specifically, it will succeed if the program
+  # does not crash but exits with a non-zero exit code. We ought to merge
+  # KillTheDoctor and not --crash to make the latter more useful and remove the
+  # need for this substitution.
+  config.substitutions.append( ("%expect_crash ", "not KillTheDoctor ") )
+else:
+  config.substitutions.append( ("%expect_crash ", "not --crash ") )
+
 # Add supported compiler_rt architectures to a list of available features.
 compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
 if compiler_rt_arch:

Modified: compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp Thu Jul  2 17:08:38 2015
@@ -23,6 +23,10 @@
 # define BYTE_ORDER _BYTE_ORDER
 # define BIG_ENDIAN _BIG_ENDIAN
 # define LITTLE_ENDIAN _LITTLE_ENDIAN
+#elif defined(_WIN32)
+# define BYTE_ORDER 0
+# define BIG_ENDIAN 1
+# define LITTLE_ENDIAN 0
 #else
 # include <endian.h>
 # define BYTE_ORDER __BYTE_ORDER
@@ -118,7 +122,7 @@ int main(int argc, char **argv) {
     // Integer -> floating point overflow.
   case '6': {
     // CHECK-6: {{runtime error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'|__int128 not supported}}
-#ifdef __SIZEOF_INT128__
+#if defined(__SIZEOF_INT128__) && !defined(_WIN32)
     static int test_int = (float)(FloatMaxAsUInt128 + 1);
     return 0;
 #else

Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/add-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/add-overflow.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Integer/add-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Integer/add-overflow.cpp Thu Jul  2 17:08:38 2015
@@ -1,6 +1,6 @@
-// RUN: %clangxx -DADD_I32 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
-// RUN: %clangxx -DADD_I64 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
-// RUN: %clangxx -DADD_I128 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
+// RUN: %clangxx -DADD_I32 -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
+// RUN: %clangxx -DADD_I64 -fsanitize=signed-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
+// RUN: %clangxx -DADD_I128 -fsanitize=signed-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
 
 #include <stdint.h>
 #include <stdio.h>
@@ -22,7 +22,7 @@ int main() {
 #endif
 
 #ifdef ADD_I128
-# ifdef __SIZEOF_INT128__
+# if defined(__SIZEOF_INT128__) && !defined(_WIN32)
   (void)((__int128_t(1) << 126) + (__int128_t(1) << 126));
 # else
   puts("__int128 not supported");

Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/div-zero.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/div-zero.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Integer/div-zero.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Integer/div-zero.cpp Thu Jul  2 17:08:38 2015
@@ -3,7 +3,7 @@
 // RUN: %clangxx -fsanitize=float-divide-by-zero -DDIVIDEND=1.5 %s -o %t && %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND='intmax(123)' %s -o %t && %run %t 2>&1 | FileCheck %s
 
-#ifdef __SIZEOF_INT128__
+#if defined(__SIZEOF_INT128__) && !defined(_WIN32)
 typedef __int128 intmax;
 #else
 typedef long long intmax;

Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/incdec-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/incdec-overflow.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Integer/incdec-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Integer/incdec-overflow.cpp Thu Jul  2 17:08:38 2015
@@ -1,7 +1,7 @@
-// RUN: %clangxx -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=PLUS
-// RUN: %clangxx -DOP=++n -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=PLUS
-// RUN: %clangxx -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=MINUS
-// RUN: %clangxx -DOP=--m -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=MINUS
+// RUN: %clangxx -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=PLUS
+// RUN: %clangxx -DOP=++n -fsanitize=signed-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=PLUS
+// RUN: %clangxx -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=MINUS
+// RUN: %clangxx -DOP=--m -fsanitize=signed-integer-overflow %s -o %t4 && %run %t4 2>&1 | FileCheck %s --check-prefix=MINUS
 
 #include <stdint.h>
 

Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/negate-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/negate-overflow.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Integer/negate-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Integer/negate-overflow.cpp Thu Jul  2 17:08:38 2015
@@ -1,5 +1,5 @@
-// RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECKS
-// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECKU
+// RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECKS
+// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECKU
 
 int main() {
   // CHECKS-NOT: runtime error

Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp Thu Jul  2 17:08:38 2015
@@ -1,20 +1,20 @@
-// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
-// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
-// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
-// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
-// RUN: %clangxx -DTOO_LOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
-// RUN: %clangxx -DTOO_LOW -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
-// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
-// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
-// RUN: %clangxx -DTOO_HIGH -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
-// RUN: %clangxx -DTOO_HIGH -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
+// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t1 && not %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
+// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t2 && not %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
+// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t3 && not %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
+// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t4 && not %run %t4 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
+// RUN: %clangxx -DTOO_LOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t5 && not %run %t5 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
+// RUN: %clangxx -DTOO_LOW -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t6 && not %run %t6 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
+// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t7 && not %run %t7 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
+// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t8 && not %run %t8 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
+// RUN: %clangxx -DTOO_HIGH -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t9 && not %run %t9 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
+// RUN: %clangxx -DTOO_HIGH -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t10 && not %run %t10 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
 
-// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && %run %t
-// RUN: %clangxx -DLSH_OVERFLOW -DOP='>>' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && %run %t
-// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
-// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
-// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
-// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
+// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t12 && %run %t12
+// RUN: %clangxx -DLSH_OVERFLOW -DOP='>>' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t13 && %run %t13
+// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t14 && %run %t14
+// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t15 && %run %t15
+// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t16 && %run %t16
+// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t17 && %run %t17
 
 #include <stdint.h>
 

Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/sub-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/sub-overflow.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Integer/sub-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Integer/sub-overflow.cpp Thu Jul  2 17:08:38 2015
@@ -1,6 +1,6 @@
-// RUN: %clangxx -DSUB_I32 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
-// RUN: %clangxx -DSUB_I64 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
-// RUN: %clangxx -DSUB_I128 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
+// RUN: %clangxx -DSUB_I32 -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
+// RUN: %clangxx -DSUB_I64 -fsanitize=signed-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
+// RUN: %clangxx -DSUB_I128 -fsanitize=signed-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
 
 #include <stdint.h>
 #include <stdio.h>
@@ -21,7 +21,7 @@ int main() {
 #endif
 
 #ifdef SUB_I128
-# ifdef __SIZEOF_INT128__
+# if defined(__SIZEOF_INT128__) && !defined(_WIN32)
   (void)(-(__int128_t(1) << 126) - (__int128_t(1) << 126) - 1);
 # else
   puts("__int128 not supported");

Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/uadd-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/uadd-overflow.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Integer/uadd-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Integer/uadd-overflow.cpp Thu Jul  2 17:08:38 2015
@@ -1,6 +1,6 @@
-// RUN: %clangxx -DADD_I32 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
-// RUN: %clangxx -DADD_I64 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
-// RUN: %clangxx -DADD_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
+// RUN: %clangxx -DADD_I32 -fsanitize=unsigned-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
+// RUN: %clangxx -DADD_I64 -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
+// RUN: %clangxx -DADD_I128 -fsanitize=unsigned-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
 
 #include <stdint.h>
 #include <stdio.h>
@@ -22,7 +22,7 @@ int main() {
 #endif
 
 #ifdef ADD_I128
-# ifdef __SIZEOF_INT128__
+# if defined(__SIZEOF_INT128__) && !defined(_WIN32)
   (void)((__uint128_t(1) << 127) + (__uint128_t(1) << 127));
 # else
   puts("__int128 not supported");

Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/uincdec-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/uincdec-overflow.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Integer/uincdec-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Integer/uincdec-overflow.cpp Thu Jul  2 17:08:38 2015
@@ -1,7 +1,7 @@
-// RUN: %clangxx -DOP=n++ -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck --check-prefix=CHECK-INC %s
-// RUN: %clangxx -DOP=++n -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck --check-prefix=CHECK-INC %s
-// RUN: %clangxx -DOP=m-- -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
-// RUN: %clangxx -DOP=--m -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
+// RUN: %clangxx -DOP=n++ -fsanitize=unsigned-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck --check-prefix=CHECK-INC %s
+// RUN: %clangxx -DOP=++n -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck --check-prefix=CHECK-INC %s
+// RUN: %clangxx -DOP=m-- -fsanitize=unsigned-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
+// RUN: %clangxx -DOP=--m -fsanitize=unsigned-integer-overflow %s -o %t4 && %run %t4 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
 
 #include <stdint.h>
 

Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/usub-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/usub-overflow.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Integer/usub-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Integer/usub-overflow.cpp Thu Jul  2 17:08:38 2015
@@ -1,6 +1,6 @@
-// RUN: %clangxx -DSUB_I32 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
-// RUN: %clangxx -DSUB_I64 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
-// RUN: %clangxx -DSUB_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
+// RUN: %clangxx -DSUB_I32 -fsanitize=unsigned-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
+// RUN: %clangxx -DSUB_I64 -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
+// RUN: %clangxx -DSUB_I128 -fsanitize=unsigned-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
 
 #include <stdint.h>
 #include <stdio.h>
@@ -21,7 +21,7 @@ int main() {
 #endif
 
 #ifdef SUB_I128
-# ifdef __SIZEOF_INT128__
+# if defined(__SIZEOF_INT128__) && !defined(_WIN32)
   (void)((__uint128_t(1) << 126) - (__uint128_t(1) << 127));
 # else
   puts("__int128 not supported\n");

Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp Thu Jul  2 17:08:38 2015
@@ -1,7 +1,7 @@
 // RUN: %clangxx -fsanitize=bounds %s -O3 -o %t
 // RUN: %run %t 0 0 0
 // RUN: %run %t 1 2 3
-// RUN: not --crash %run %t 2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK-A-2
+// RUN: %expect_crash %run %t 2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK-A-2
 // RUN: %run %t 0 3 0 2>&1 | FileCheck %s --check-prefix=CHECK-B-3
 // RUN: %run %t 0 0 4 2>&1 | FileCheck %s --check-prefix=CHECK-C-4
 

Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/deduplication.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/deduplication.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Misc/deduplication.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Misc/deduplication.cpp Thu Jul  2 17:08:38 2015
@@ -11,6 +11,7 @@ void overflow() {
 int main() {
   // CHECK: Start
   fprintf(stderr, "Start\n");
+  fflush(stderr);
 
   // CHECK: runtime error
   // CHECK-NOT: runtime error

Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp Thu Jul  2 17:08:38 2015
@@ -2,6 +2,10 @@
 // RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E" %s -O3 -o %t && %run %t
 // RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL
 
+// FIXME: UBSan fails to add the correct instrumentation code for some reason on
+// Windows.
+// XFAIL: win32
+
 enum E { a = 1 } e;
 #undef E
 

Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp Thu Jul  2 17:08:38 2015
@@ -1,6 +1,6 @@
 // RUN: %clangxx -fsanitize=return -g %s -O3 -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
-// RUN: UBSAN_OPTIONS=print_stacktrace=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%os-STACKTRACE
+// RUN: env UBSAN_OPTIONS=print_stacktrace=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%os-STACKTRACE
 
 // CHECK: missing_return.cpp:[[@LINE+1]]:5: runtime error: execution reached the end of a value-returning function without returning a value
 int f() {

Modified: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/misaligned.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/misaligned.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/misaligned.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/misaligned.cpp Thu Jul  2 17:08:38 2015
@@ -7,7 +7,7 @@
 // RUN: %run %t f1 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
 // RUN: %run %t n1 2>&1 | FileCheck %s --check-prefix=CHECK-NEW
 // RUN: %run %t u1 2>&1 | FileCheck %s --check-prefix=CHECK-UPCAST
-// RUN: UBSAN_OPTIONS=print_stacktrace=1 %run %t l1 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD --check-prefix=CHECK-%os-STACK-LOAD
+// RUN: env UBSAN_OPTIONS=print_stacktrace=1 %run %t l1 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD --check-prefix=CHECK-%os-STACK-LOAD
 
 // RUN: %clangxx -fsanitize=alignment -fno-sanitize-recover=alignment %s -O3 -o %t
 // RUN: not %run %t w1 2>&1 | FileCheck %s --check-prefix=CHECK-WILD
@@ -38,7 +38,7 @@ int main(int, char **argv) {
 
   switch (argv[1][0]) {
   case 'l':
-    // CHECK-LOAD: misaligned.cpp:[[@LINE+4]]:12: runtime error: load of misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
+    // CHECK-LOAD: misaligned.cpp:[[@LINE+4]]{{(:12)?}}: runtime error: load of misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
     // CHECK-LOAD-NEXT: [[PTR]]: note: pointer points here
     // CHECK-LOAD-NEXT: {{^ 00 00 00 01 02 03 04  05}}
     // CHECK-LOAD-NEXT: {{^             \^}}
@@ -50,7 +50,7 @@ int main(int, char **argv) {
     // CHECK-Darwin-STACK-LOAD: {{ }}
 
   case 's':
-    // CHECK-STORE: misaligned.cpp:[[@LINE+4]]:5: runtime error: store to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
+    // CHECK-STORE: misaligned.cpp:[[@LINE+4]]{{(:5)?}}: runtime error: store to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
     // CHECK-STORE-NEXT: [[PTR]]: note: pointer points here
     // CHECK-STORE-NEXT: {{^ 00 00 00 01 02 03 04  05}}
     // CHECK-STORE-NEXT: {{^             \^}}
@@ -58,7 +58,7 @@ int main(int, char **argv) {
     break;
 
   case 'r':
-    // CHECK-REFERENCE: misaligned.cpp:[[@LINE+4]]:15: runtime error: reference binding to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
+    // CHECK-REFERENCE: misaligned.cpp:[[@LINE+4]]{{(:(5|15))?}}: runtime error: reference binding to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
     // CHECK-REFERENCE-NEXT: [[PTR]]: note: pointer points here
     // CHECK-REFERENCE-NEXT: {{^ 00 00 00 01 02 03 04  05}}
     // CHECK-REFERENCE-NEXT: {{^             \^}}
@@ -66,28 +66,28 @@ int main(int, char **argv) {
     break;
 
   case 'm':
-    // CHECK-MEMBER: misaligned.cpp:[[@LINE+4]]:15: runtime error: member access within misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
+    // CHECK-MEMBER: misaligned.cpp:[[@LINE+4]]{{(:15)?}}: runtime error: member access within misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
     // CHECK-MEMBER-NEXT: [[PTR]]: note: pointer points here
     // CHECK-MEMBER-NEXT: {{^ 00 00 00 01 02 03 04  05}}
     // CHECK-MEMBER-NEXT: {{^             \^}}
     return s->k && 0;
 
   case 'f':
-    // CHECK-MEMFUN: misaligned.cpp:[[@LINE+4]]:12: runtime error: member call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
+    // CHECK-MEMFUN: misaligned.cpp:[[@LINE+4]]{{(:12)?}}: runtime error: member call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
     // CHECK-MEMFUN-NEXT: [[PTR]]: note: pointer points here
     // CHECK-MEMFUN-NEXT: {{^ 00 00 00 01 02 03 04  05}}
     // CHECK-MEMFUN-NEXT: {{^             \^}}
     return s->f() && 0;
 
   case 'n':
-    // CHECK-NEW: misaligned.cpp:[[@LINE+4]]:21: runtime error: constructor call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
+    // CHECK-NEW: misaligned.cpp:[[@LINE+4]]{{(:21)?}}: runtime error: constructor call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
     // CHECK-NEW-NEXT: [[PTR]]: note: pointer points here
     // CHECK-NEW-NEXT: {{^ 00 00 00 01 02 03 04  05}}
     // CHECK-NEW-NEXT: {{^             \^}}
     return (new (s) S)->k && 0;
 
   case 'u': {
-    // CHECK-UPCAST: misaligned.cpp:[[@LINE+4]]:17: runtime error: upcast of misaligned address [[PTR:0x[0-9a-f]*]] for type 'T', which requires 4 byte alignment
+    // CHECK-UPCAST: misaligned.cpp:[[@LINE+4]]{{(:17)?}}: runtime error: upcast of misaligned address [[PTR:0x[0-9a-f]*]] for type 'T', which requires 4 byte alignment
     // CHECK-UPCAST-NEXT: [[PTR]]: note: pointer points here
     // CHECK-UPCAST-NEXT: {{^ 00 00 00 01 02 03 04  05}}
     // CHECK-UPCAST-NEXT: {{^             \^}}
@@ -96,7 +96,7 @@ int main(int, char **argv) {
   }
 
   case 'w':
-    // CHECK-WILD: misaligned.cpp:[[@LINE+3]]:35: runtime error: member access within misaligned address 0x{{0+}}123 for type 'S', which requires 4 byte alignment
+    // CHECK-WILD: misaligned.cpp:[[@LINE+3]]{{(:35)?}}: runtime error: member access within misaligned address 0x{{0+}}123 for type 'S', which requires 4 byte alignment
     // CHECK-WILD-NEXT: 0x{{0+}}123: note: pointer points here
     // CHECK-WILD-NEXT: <memory cannot be printed>
     return static_cast<S*>(wild)->k;

Modified: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp Thu Jul  2 17:08:38 2015
@@ -1,6 +1,6 @@
 // RUN: %clangxx -fsanitize=null %s -O3 -o %t
 // RUN: %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD
-// RUN: not --crash %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
+// RUN: %expect_crash %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
 // RUN: %run %t r 2>&1 | FileCheck %s --check-prefix=CHECK-REFERENCE
 // RUN: %run %t m 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
 // RUN: %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN

Modified: compiler-rt/trunk/test/ubsan/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/lit.common.cfg?rev=241303&r1=241302&r2=241303&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/lit.common.cfg (original)
+++ compiler-rt/trunk/test/ubsan/lit.common.cfg Thu Jul  2 17:08:38 2015
@@ -51,7 +51,7 @@ config.substitutions.append( ("%clangxx
 config.suffixes = ['.c', '.cc', '.cpp']
 
 # Check that the host supports UndefinedBehaviorSanitizer tests
-if config.host_os not in ['Linux', 'Darwin', 'FreeBSD']:
+if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'Windows']:
   config.unsupported = True
 
 # Allow tests to use REQUIRES=stable-runtime.  For use when you cannot use XFAIL





More information about the llvm-commits mailing list