summaryrefslogtreecommitdiff
path: root/lib/ubsan/lit_tests/TestCases/Integer
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ubsan/lit_tests/TestCases/Integer')
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/add-overflow.cpp32
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/div-overflow.cpp10
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/div-zero.cpp15
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/incdec-overflow.cpp16
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/mul-overflow.cpp14
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/negate-overflow.cpp12
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/no-recover.cpp22
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/shift.cpp37
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/sub-overflow.cpp31
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/uadd-overflow.cpp32
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/uincdec-overflow.cpp16
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/umul-overflow.cpp19
-rw-r--r--lib/ubsan/lit_tests/TestCases/Integer/usub-overflow.cpp31
13 files changed, 0 insertions, 287 deletions
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/add-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/add-overflow.cpp
deleted file mode 100644
index 412eb7621033b..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/add-overflow.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// RUN: %clangxx -DADD_I32 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
-// RUN: %clangxx -DADD_I64 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
-// RUN: %clangxx -DADD_I128 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
-
-#include <stdint.h>
-#include <stdio.h>
-
-int main() {
- // These promote to 'int'.
- (void)(int8_t(0x7f) + int8_t(0x7f));
- (void)(int16_t(0x3fff) + int16_t(0x4000));
-
-#ifdef ADD_I32
- int32_t k = 0x12345678;
- k += 0x789abcde;
- // CHECK-ADD_I32: add-overflow.cpp:[[@LINE-1]]:5: runtime error: signed integer overflow: 305419896 + 2023406814 cannot be represented in type 'int'
-#endif
-
-#ifdef ADD_I64
- (void)(int64_t(8000000000000000000ll) + int64_t(2000000000000000000ll));
- // CHECK-ADD_I64: 8000000000000000000 + 2000000000000000000 cannot be represented in type '{{long( long)?}}'
-#endif
-
-#ifdef ADD_I128
-# ifdef __SIZEOF_INT128__
- (void)((__int128_t(1) << 126) + (__int128_t(1) << 126));
-# else
- puts("__int128 not supported");
-# endif
- // CHECK-ADD_I128: {{0x40000000000000000000000000000000 \+ 0x40000000000000000000000000000000 cannot be represented in type '__int128'|__int128 not supported}}
-#endif
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/div-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/div-overflow.cpp
deleted file mode 100644
index 83aa854485b40..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/div-overflow.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
-
-#include <stdint.h>
-
-int main() {
- unsigned(0x80000000) / -1;
-
- // CHECK: div-overflow.cpp:9:23: runtime error: division of -2147483648 by -1 cannot be represented in type 'int'
- int32_t(0x80000000) / -1;
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/div-zero.cpp b/lib/ubsan/lit_tests/TestCases/Integer/div-zero.cpp
deleted file mode 100644
index 6b8aadfe15e69..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/div-zero.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND=0 %s -o %t && %t 2>&1 | FileCheck %s
-// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND=1U %s -o %t && %t 2>&1 | FileCheck %s
-// RUN: %clangxx -fsanitize=float-divide-by-zero -DDIVIDEND=1.5 %s -o %t && %t 2>&1 | FileCheck %s
-// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND='intmax(123)' %s -o %t && %t 2>&1 | FileCheck %s
-
-#ifdef __SIZEOF_INT128__
-typedef __int128 intmax;
-#else
-typedef long long intmax;
-#endif
-
-int main() {
- // CHECK: div-zero.cpp:[[@LINE+1]]:12: runtime error: division by zero
- DIVIDEND / 0;
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/incdec-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/incdec-overflow.cpp
deleted file mode 100644
index 904250a76c793..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/incdec-overflow.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clangxx -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
-// RUN: %clangxx -DOP=++n -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
-// RUN: %clangxx -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
-// RUN: %clangxx -DOP=--m -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
-
-#include <stdint.h>
-
-int main() {
- int n = 0x7ffffffd;
- n++;
- n++;
- int m = -n - 1;
- // CHECK: incdec-overflow.cpp:15:3: runtime error: signed integer overflow: [[MINUS:-?]]214748364
- // CHECK: + [[MINUS]]1 cannot be represented in type 'int'
- OP;
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/mul-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/mul-overflow.cpp
deleted file mode 100644
index 1cfe23f57213c..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/mul-overflow.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
-
-#include <stdint.h>
-
-int main() {
- // These promote to 'int'.
- (void)(int8_t(-2) * int8_t(0x7f));
- (void)(int16_t(0x7fff) * int16_t(0x7fff));
- (void)(uint16_t(0xffff) * int16_t(0x7fff));
- (void)(uint16_t(0xffff) * uint16_t(0x8000));
-
- // CHECK: mul-overflow.cpp:13:27: runtime error: signed integer overflow: 65535 * 32769 cannot be represented in type 'int'
- (void)(uint16_t(0xffff) * uint16_t(0x8001));
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/negate-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/negate-overflow.cpp
deleted file mode 100644
index 6bee3eea29802..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/negate-overflow.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECKS
-// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECKU
-
-int main() {
- // CHECKS-NOT: runtime error
- // CHECKU: negate-overflow.cpp:[[@LINE+2]]:3: runtime error: negation of 2147483648 cannot be represented in type 'unsigned int'
- // CHECKU-NOT: cast to an unsigned
- -unsigned(-0x7fffffff - 1); // ok
- // CHECKS: negate-overflow.cpp:[[@LINE+2]]:10: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
- // CHECKU-NOT: runtime error
- return -(-0x7fffffff - 1);
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/no-recover.cpp b/lib/ubsan/lit_tests/TestCases/Integer/no-recover.cpp
deleted file mode 100644
index 64787b7cfbf55..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/no-recover.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=RECOVER
-// RUN: %clangxx -fsanitize=unsigned-integer-overflow -fsanitize-recover %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=RECOVER
-// RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=ABORT
-
-#include <stdint.h>
-
-int main() {
- // These promote to 'int'.
- (void)(uint8_t(0xff) + uint8_t(0xff));
- (void)(uint16_t(0xf0fff) + uint16_t(0x0fff));
- // RECOVER-NOT: runtime error
- // ABORT-NOT: runtime error
-
- uint32_t k = 0x87654321;
- k += 0xedcba987;
- // RECOVER: no-recover.cpp:[[@LINE-1]]:5: runtime error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'unsigned int'
- // ABORT: no-recover.cpp:[[@LINE-2]]:5: runtime error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'unsigned int'
-
- (void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
- // RECOVER: 10000000000000000000 + 9000000000000000000 cannot be represented in type 'unsigned {{long( long)?}}'
- // ABORT-NOT: runtime error
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/shift.cpp b/lib/ubsan/lit_tests/TestCases/Integer/shift.cpp
deleted file mode 100644
index f35fa1f959ae5..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/shift.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
-// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<=' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
-// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
-// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
-// RUN: %clangxx -DTOO_LOW -DOP='<<=' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
-// RUN: %clangxx -DTOO_LOW -DOP='>>=' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
-// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
-// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
-// RUN: %clangxx -DTOO_HIGH -DOP='<<=' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
-// RUN: %clangxx -DTOO_HIGH -DOP='>>=' -fsanitize=shift %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
-
-#include <stdint.h>
-
-int main() {
- int a = 1;
- unsigned b = 1;
-
- a <<= 31; // ok in C++11, not ok in C99/C11
- b <<= 31; // ok
- b <<= 1; // still ok, unsigned
-
-#ifdef LSH_OVERFLOW
- // CHECK-LSH_OVERFLOW: shift.cpp:24:5: runtime error: left shift of negative value -2147483648
- a OP 1;
-#endif
-
-#ifdef TOO_LOW
- // CHECK-TOO_LOW: shift.cpp:29:5: runtime error: shift exponent -3 is negative
- a OP (-3);
-#endif
-
-#ifdef TOO_HIGH
- a = 0;
- // CHECK-TOO_HIGH: shift.cpp:35:5: runtime error: shift exponent 32 is too large for 32-bit type 'int'
- a OP 32;
-#endif
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/sub-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/sub-overflow.cpp
deleted file mode 100644
index bf33d293799bb..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/sub-overflow.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// RUN: %clangxx -DSUB_I32 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
-// RUN: %clangxx -DSUB_I64 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
-// RUN: %clangxx -DSUB_I128 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
-
-#include <stdint.h>
-#include <stdio.h>
-
-int main() {
- // These promote to 'int'.
- (void)(int8_t(-2) - int8_t(0x7f));
- (void)(int16_t(-2) - int16_t(0x7fff));
-
-#ifdef SUB_I32
- (void)(int32_t(-2) - int32_t(0x7fffffff));
- // CHECK-SUB_I32: sub-overflow.cpp:[[@LINE-1]]:22: runtime error: signed integer overflow: -2 - 2147483647 cannot be represented in type 'int'
-#endif
-
-#ifdef SUB_I64
- (void)(int64_t(-8000000000000000000ll) - int64_t(2000000000000000000ll));
- // CHECK-SUB_I64: -8000000000000000000 - 2000000000000000000 cannot be represented in type '{{long( long)?}}'
-#endif
-
-#ifdef SUB_I128
-# ifdef __SIZEOF_INT128__
- (void)(-(__int128_t(1) << 126) - (__int128_t(1) << 126) - 1);
-# else
- puts("__int128 not supported");
-# endif
- // CHECK-SUB_I128: {{0x80000000000000000000000000000000 - 1 cannot be represented in type '__int128'|__int128 not supported}}
-#endif
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/uadd-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/uadd-overflow.cpp
deleted file mode 100644
index 2ef31c0640d15..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/uadd-overflow.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// RUN: %clangxx -DADD_I32 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
-// RUN: %clangxx -DADD_I64 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
-// RUN: %clangxx -DADD_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
-
-#include <stdint.h>
-#include <stdio.h>
-
-int main() {
- // These promote to 'int'.
- (void)(uint8_t(0xff) + uint8_t(0xff));
- (void)(uint16_t(0xf0fff) + uint16_t(0x0fff));
-
-#ifdef ADD_I32
- uint32_t k = 0x87654321;
- k += 0xedcba987;
- // CHECK-ADD_I32: uadd-overflow.cpp:[[@LINE-1]]:5: runtime error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'unsigned int'
-#endif
-
-#ifdef ADD_I64
- (void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
- // CHECK-ADD_I64: 10000000000000000000 + 9000000000000000000 cannot be represented in type 'unsigned {{long( long)?}}'
-#endif
-
-#ifdef ADD_I128
-# ifdef __SIZEOF_INT128__
- (void)((__uint128_t(1) << 127) + (__uint128_t(1) << 127));
-# else
- puts("__int128 not supported");
-# endif
- // CHECK-ADD_I128: {{0x80000000000000000000000000000000 \+ 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
-#endif
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/uincdec-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/uincdec-overflow.cpp
deleted file mode 100644
index a14bd6a776f51..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/uincdec-overflow.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clangxx -DOP=n++ -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck --check-prefix=CHECK-INC %s
-// RUN: %clangxx -DOP=++n -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck --check-prefix=CHECK-INC %s
-// RUN: %clangxx -DOP=m-- -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
-// RUN: %clangxx -DOP=--m -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
-
-#include <stdint.h>
-
-int main() {
- unsigned n = 0xfffffffd;
- n++;
- n++;
- unsigned m = 0;
- // CHECK-INC: uincdec-overflow.cpp:15:3: runtime error: unsigned integer overflow: 4294967295 + 1 cannot be represented in type 'unsigned int'
- // CHECK-DEC: uincdec-overflow.cpp:15:3: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
- OP;
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/umul-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/umul-overflow.cpp
deleted file mode 100644
index c84bb39ef2f73..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/umul-overflow.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
-
-#include <stdint.h>
-
-int main() {
- // These promote to 'int'.
- (void)(int8_t(-2) * int8_t(0x7f));
- (void)(int16_t(0x7fff) * int16_t(0x7fff));
- (void)(uint16_t(0xffff) * int16_t(0x7fff));
- (void)(uint16_t(0xffff) * uint16_t(0x8000));
-
- // Not an unsigned overflow
- (void)(uint16_t(0xffff) * uint16_t(0x8001));
-
- (void)(uint32_t(0xffffffff) * uint32_t(0x2));
- // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
-
- return 0;
-}
diff --git a/lib/ubsan/lit_tests/TestCases/Integer/usub-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/usub-overflow.cpp
deleted file mode 100644
index 78f7455785833..0000000000000
--- a/lib/ubsan/lit_tests/TestCases/Integer/usub-overflow.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// RUN: %clangxx -DSUB_I32 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
-// RUN: %clangxx -DSUB_I64 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
-// RUN: %clangxx -DSUB_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
-
-#include <stdint.h>
-#include <stdio.h>
-
-int main() {
- // These promote to 'int'.
- (void)(uint8_t(0) - uint8_t(0x7f));
- (void)(uint16_t(0) - uint16_t(0x7fff));
-
-#ifdef SUB_I32
- (void)(uint32_t(1) - uint32_t(2));
- // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
-#endif
-
-#ifdef SUB_I64
- (void)(uint64_t(8000000000000000000ll) - uint64_t(9000000000000000000ll));
- // CHECK-SUB_I64: 8000000000000000000 - 9000000000000000000 cannot be represented in type 'unsigned {{long( long)?}}'
-#endif
-
-#ifdef SUB_I128
-# ifdef __SIZEOF_INT128__
- (void)((__uint128_t(1) << 126) - (__uint128_t(1) << 127));
-# else
- puts("__int128 not supported\n");
-# endif
- // CHECK-SUB_I128: {{0x40000000000000000000000000000000 - 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
-#endif
-}