[ubsan] Replace "fatal error" with "runtime error".

llvm-svn: 169112
This commit is contained in:
Will Dietz 2012-12-02 18:43:33 +00:00
parent 1157e1410c
commit b28179be10
21 changed files with 44 additions and 44 deletions

View File

@ -53,28 +53,28 @@ int main(int argc, char **argv) {
case '0':
// Note that values between 0x7ffffe00 and 0x80000000 may or may not
// successfully round-trip, depending on the rounding mode.
// CHECK-0: fatal error: value 2.14748{{.*}} is outside the range of representable values of type 'int'
// CHECK-0: runtime error: value 2.14748{{.*}} is outside the range of representable values of type 'int'
return MaxFloatRepresentableAsInt + 0x80;
case '1':
// CHECK-1: fatal error: value -2.14748{{.*}} is outside the range of representable values of type 'int'
// CHECK-1: runtime error: value -2.14748{{.*}} is outside the range of representable values of type 'int'
return MinFloatRepresentableAsInt - 0x100;
case '2':
// CHECK-2: fatal error: value -0.001 is outside the range of representable values of type 'unsigned int'
// CHECK-2: runtime error: value -0.001 is outside the range of representable values of type 'unsigned int'
return (unsigned)-0.001;
case '3':
// CHECK-3: fatal error: value 4.2949{{.*}} is outside the range of representable values of type 'unsigned int'
// CHECK-3: runtime error: value 4.2949{{.*}} is outside the range of representable values of type 'unsigned int'
return (unsigned)(MaxFloatRepresentableAsUInt + 0x100);
case '4':
// CHECK-4: fatal error: value {{.*}} is outside the range of representable values of type 'int'
// CHECK-4: runtime error: value {{.*}} is outside the range of representable values of type 'int'
return Inf;
case '5':
// CHECK-5: fatal error: value {{.*}} is outside the range of representable values of type 'int'
// CHECK-5: runtime error: value {{.*}} is outside the range of representable values of type 'int'
return NaN;
// Integer -> floating point overflow.
case '6':
// CHECK-6: {{fatal error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'|__int128 not supported}}
// CHECK-6: {{runtime error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'|__int128 not supported}}
#ifdef __SIZEOF_INT128__
return (float)(FloatMaxAsUInt128 + 1);
#else
@ -84,15 +84,15 @@ int main(int argc, char **argv) {
// FIXME: The backend cannot lower __fp16 operations on x86 yet.
//case '7':
// (__fp16)65504; // ok
// // CHECK-7: fatal error: value 65505 is outside the range of representable values of type '__fp16'
// // CHECK-7: runtime error: value 65505 is outside the range of representable values of type '__fp16'
// return (__fp16)65505;
// Floating point -> floating point overflow.
case '8':
// CHECK-8: fatal error: value 1e+39 is outside the range of representable values of type 'float'
// CHECK-8: runtime error: value 1e+39 is outside the range of representable values of type 'float'
return (float)1e39;
case '9':
// CHECK-9: fatal error: value {{.*}} is outside the range of representable values of type 'double'
// CHECK-9: runtime error: value {{.*}} is outside the range of representable values of type 'double'
return (double)Inf;
}
}

View File

@ -13,7 +13,7 @@ int main() {
#ifdef ADD_I32
int32_t k = 0x12345678;
k += 0x789abcde;
// CHECK-ADD_I32: add-overflow.cpp:[[@LINE-1]]:5: fatal error: signed integer overflow: 305419896 + 2023406814 cannot be represented in type 'int32_t' (aka 'int')
// CHECK-ADD_I32: add-overflow.cpp:[[@LINE-1]]:5: runtime error: signed integer overflow: 305419896 + 2023406814 cannot be represented in type 'int32_t' (aka 'int')
#endif
#ifdef ADD_I64

View File

@ -5,6 +5,6 @@
int main() {
unsigned(0x80000000) / -1;
// CHECK: div-overflow.cpp:9:23: fatal error: division of -2147483648 by -1 cannot be represented in type 'int'
// CHECK: div-overflow.cpp:9:23: runtime error: division of -2147483648 by -1 cannot be represented in type 'int'
int32_t(0x80000000) / -1;
}

View File

@ -10,6 +10,6 @@ typedef long long intmax;
#endif
int main() {
// CHECK: div-zero.cpp:[[@LINE+1]]:12: fatal error: division by zero
// CHECK: div-zero.cpp:[[@LINE+1]]:12: runtime error: division by zero
DIVIDEND / 0;
}

View File

@ -10,7 +10,7 @@ int main() {
n++;
n++;
int m = -n - 1;
// CHECK: incdec-overflow.cpp:15:3: fatal error: signed integer overflow: [[MINUS:-?]]214748364
// CHECK: incdec-overflow.cpp:15:3: runtime error: signed integer overflow: [[MINUS:-?]]214748364
// CHECK: + [[MINUS]]1 cannot be represented in type 'int'
OP;
}

View File

@ -9,6 +9,6 @@ int main() {
(void)(uint16_t(0xffff) * int16_t(0x7fff));
(void)(uint16_t(0xffff) * uint16_t(0x8000));
// CHECK: mul-overflow.cpp:13:27: fatal error: signed integer overflow: 65535 * 32769 cannot be represented in type 'int'
// 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));
}

View File

@ -2,6 +2,6 @@
int main() {
-unsigned(-0x7fffffff - 1); // ok
// CHECK: negate-overflow.cpp:6:10: fatal error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
// CHECK: negate-overflow.cpp:6:10: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
return -(-0x7fffffff - 1);
}

View File

@ -20,18 +20,18 @@ int main() {
b <<= 1; // still ok, unsigned
#ifdef LSH_OVERFLOW
// CHECK-LSH_OVERFLOW: shift.cpp:24:5: fatal error: left shift of negative value -2147483648
// 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: fatal error: shift exponent -3 is negative
// 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: fatal error: shift exponent 32 is too large for 32-bit type 'int'
// CHECK-TOO_HIGH: shift.cpp:35:5: runtime error: shift exponent 32 is too large for 32-bit type 'int'
a OP 32;
#endif
}

View File

@ -12,7 +12,7 @@ int main() {
#ifdef SUB_I32
(void)(int32_t(-2) - int32_t(0x7fffffff));
// CHECK-SUB_I32: sub-overflow.cpp:[[@LINE-1]]:22: fatal error: signed integer overflow: -2 - 2147483647 cannot be represented in type 'int'
// 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

View File

@ -13,7 +13,7 @@ int main() {
#ifdef ADD_I32
uint32_t k = 0x87654321;
k += 0xedcba987;
// CHECK-ADD_I32: uadd-overflow.cpp:[[@LINE-1]]:5: fatal error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'uint32_t' (aka 'unsigned int')
// CHECK-ADD_I32: uadd-overflow.cpp:[[@LINE-1]]:5: runtime error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'uint32_t' (aka 'unsigned int')
#endif
#ifdef ADD_I64

View File

@ -10,7 +10,7 @@ int main() {
n++;
n++;
unsigned m = 0;
// CHECK-INC: uincdec-overflow.cpp:15:3: fatal error: unsigned integer overflow: 4294967295 + 1 cannot be represented in type 'unsigned int'
// CHECK-DEC: uincdec-overflow.cpp:15:3: fatal error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
// 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;
}

View File

@ -13,7 +13,7 @@ int main() {
(void)(uint16_t(0xffff) * uint16_t(0x8001));
(void)(uint32_t(0xffffffff) * uint32_t(0x2));
// CHECK: umul-overflow.cpp:15:31: fatal error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
// CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
return 0;
}

View File

@ -12,7 +12,7 @@ int main() {
#ifdef SUB_I32
(void)(uint32_t(1) - uint32_t(2));
// CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: fatal error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
// 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

View File

@ -1,6 +1,6 @@
// RUN: %clang -fsanitize=return %s -O3 -o %t && %t 2>&1 | FileCheck %s
// CHECK: missing_return.cpp:4:5: fatal error: execution reached the end of a value-returning function without returning a value
// CHECK: missing_return.cpp:4:5: runtime error: execution reached the end of a value-returning function without returning a value
int f() {
}

View File

@ -1,6 +1,6 @@
// RUN: %clang -fsanitize=unreachable %s -O3 -o %t && %t 2>&1 | FileCheck %s
int main(int, char **argv) {
// CHECK: unreachable.cpp:5:3: fatal error: execution reached a __builtin_unreachable() call
// CHECK: unreachable.cpp:5:3: runtime error: execution reached a __builtin_unreachable() call
__builtin_unreachable();
}

View File

@ -4,8 +4,8 @@
// RUN: %t a b
int main(int argc, char **argv) {
// CHECK-MINUS-ONE: vla.c:9:11: fatal error: variable length array bound evaluates to non-positive value -1
// CHECK-ZERO: vla.c:9:11: fatal error: variable length array bound evaluates to non-positive value 0
// CHECK-MINUS-ONE: vla.c:9:11: runtime error: variable length array bound evaluates to non-positive value -1
// CHECK-ZERO: vla.c:9:11: runtime error: variable length array bound evaluates to non-positive value 0
int arr[argc - 2];
return 0;
}

View File

@ -22,21 +22,21 @@ int main(int, char **argv) {
switch (argv[1][0]) {
case 'l':
// CHECK-LOAD: misaligned.cpp:26:12: fatal error: load of misaligned address 0x{{[0-9a-f]*}} for type 'int', which requires 4 byte alignment
// CHECK-LOAD: misaligned.cpp:26:12: runtime error: load of misaligned address 0x{{[0-9a-f]*}} for type 'int', which requires 4 byte alignment
return *p;
case 's':
// CHECK-STORE: misaligned.cpp:29:5: fatal error: store to misaligned address 0x{{[0-9a-f]*}} for type 'int', which requires 4 byte alignment
// CHECK-STORE: misaligned.cpp:29:5: runtime error: store to misaligned address 0x{{[0-9a-f]*}} for type 'int', which requires 4 byte alignment
*p = 1;
break;
case 'r':
// CHECK-REFERENCE: misaligned.cpp:33:15: fatal error: reference binding to misaligned address 0x{{[0-9a-f]*}} for type 'int', which requires 4 byte alignment
// CHECK-REFERENCE: misaligned.cpp:33:15: runtime error: reference binding to misaligned address 0x{{[0-9a-f]*}} for type 'int', which requires 4 byte alignment
{int &r = *p;}
break;
case 'm':
// CHECK-MEMBER: misaligned.cpp:37:15: fatal error: member access within misaligned address 0x{{[0-9a-f]*}} for type 'S', which requires 4 byte alignment
// CHECK-MEMBER: misaligned.cpp:37:15: runtime error: member access within misaligned address 0x{{[0-9a-f]*}} for type 'S', which requires 4 byte alignment
return s->k;
case 'f':
// CHECK-MEMFUN: misaligned.cpp:40:12: fatal error: member call on misaligned address 0x{{[0-9a-f]*}} for type 'S', which requires 4 byte alignment
// CHECK-MEMFUN: misaligned.cpp:40:12: runtime error: member call on misaligned address 0x{{[0-9a-f]*}} for type 'S', which requires 4 byte alignment
return s->f();
}
}

View File

@ -18,21 +18,21 @@ int main(int, char **argv) {
switch (argv[1][0]) {
case 'l':
// CHECK-LOAD: null.cpp:22:12: fatal error: load of null pointer of type 'int'
// CHECK-LOAD: null.cpp:22:12: runtime error: load of null pointer of type 'int'
return *p;
case 's':
// CHECK-STORE: null.cpp:25:5: fatal error: store to null pointer of type 'int'
// CHECK-STORE: null.cpp:25:5: runtime error: store to null pointer of type 'int'
*p = 1;
break;
case 'r':
// CHECK-REFERENCE: null.cpp:29:15: fatal error: reference binding to null pointer of type 'int'
// CHECK-REFERENCE: null.cpp:29:15: runtime error: reference binding to null pointer of type 'int'
{int &r = *p;}
break;
case 'm':
// CHECK-MEMBER: null.cpp:33:15: fatal error: member access within null pointer of type 'S'
// CHECK-MEMBER: null.cpp:33:15: runtime error: member access within null pointer of type 'S'
return s->k;
case 'f':
// CHECK-MEMFUN: null.cpp:36:12: fatal error: member call on null pointer of type 'S'
// CHECK-MEMFUN: null.cpp:36:12: runtime error: member call on null pointer of type 'S'
return s->f();
}
}

View File

@ -64,14 +64,14 @@ int main(int, char **argv) {
switch (argv[1][0]) {
case 'r':
// CHECK-REFERENCE: vptr.cpp:[[@LINE+1]]:13: fatal error: reference binding to address 0x{{[0-9a-f]*}} which does not point to an object of type 'T'
// CHECK-REFERENCE: vptr.cpp:[[@LINE+1]]:13: runtime error: reference binding to address 0x{{[0-9a-f]*}} which does not point to an object of type 'T'
{T &r = *p;}
break;
case 'm':
// CHECK-MEMBER: vptr.cpp:[[@LINE+1]]:15: fatal error: member access within address 0x{{[0-9a-f]*}} which does not point to an object of type 'T'
// CHECK-MEMBER: vptr.cpp:[[@LINE+1]]:15: runtime error: member access within address 0x{{[0-9a-f]*}} which does not point to an object of type 'T'
return p->b;
case 'f':
// CHECK-MEMFUN: vptr.cpp:[[@LINE+1]]:12: fatal error: member call on address 0x{{[0-9a-f]*}} which does not point to an object of type 'T'
// CHECK-MEMFUN: vptr.cpp:[[@LINE+1]]:12: runtime error: member call on address 0x{{[0-9a-f]*}} which does not point to an object of type 'T'
return p->g();
}
}

View File

@ -60,7 +60,7 @@ Diag::~Diag() {
}
if (UseAnsiColor)
RawWrite("\033[31m");
RawWrite(" fatal error: ");
RawWrite(" runtime error: ");
if (UseAnsiColor)
RawWrite("\033[0;1m");
for (const char *Msg = Message; *Msg; ++Msg) {

View File

@ -36,7 +36,7 @@ void __ubsan::__ubsan_handle_dynamic_type_cache_miss(
<< TypeCheckKinds[Data->TypeCheckKind] << (void*)Pointer << Data->Type;
// FIXME: If possible, say what type it actually points to. Produce a note
// pointing out the vptr:
// lib/VMCore/Instructions.cpp:2020:10: fatal error: member call on address
// lib/VMCore/Instructions.cpp:2020:10: runtime error: member call on address
// 0xb7a4440 which does not point to an object of type
// 'llvm::OverflowingBinaryOperator'
// return cast<OverflowingBinaryOperator>(this)->hasNoSignedWrap();