Index: lib/ubsan/ubsan_diag.h =================================================================== --- lib/ubsan/ubsan_diag.h +++ lib/ubsan/ubsan_diag.h @@ -128,6 +128,9 @@ /// The diagnostic level. DiagLevel Level; + /// The name of the sanitizer which triggered the message. + const char *SanitizerName; + /// The message which will be emitted, with %0, %1, ... placeholders for /// arguments. const char *Message; @@ -192,8 +195,8 @@ Diag &operator=(const Diag &); public: - Diag(Location Loc, DiagLevel Level, const char *Message) - : Loc(Loc), Level(Level), Message(Message), NumArgs(0), NumRanges(0) {} + Diag(Location Loc, DiagLevel Level, const char *SanitizerName, const char *Message) + : Loc(Loc), Level(Level), SanitizerName(SanitizerName), Message(Message), NumArgs(0), NumRanges(0) {} ~Diag(); Diag &operator<<(const char *Str) { return AddArg(Str); } Index: lib/ubsan/ubsan_diag.cc =================================================================== --- lib/ubsan/ubsan_diag.cc +++ lib/ubsan/ubsan_diag.cc @@ -316,12 +316,12 @@ switch (Level) { case DL_Error: - Printf("%s runtime error: %s%s", - Decor.Warning(), Decor.EndWarning(), Decor.Bold()); + Printf("%s UndefinedBehaviorSanitizer %s error: %s%s", + Decor.Warning(), SanitizerName, Decor.EndWarning(), Decor.Bold()); break; case DL_Note: - Printf("%s note: %s", Decor.Note(), Decor.EndNote()); + Printf("%s UndefinedBehaviorSanitizer %s note: %s", Decor.Note(), SanitizerName, Decor.EndNote()); break; } Index: lib/ubsan/ubsan_handlers.cc =================================================================== --- lib/ubsan/ubsan_handlers.cc +++ lib/ubsan/ubsan_handlers.cc @@ -16,6 +16,8 @@ #include "sanitizer_common/sanitizer_common.h" +#include + using namespace __sanitizer; using namespace __ubsan; @@ -47,21 +49,29 @@ Loc = FallbackLoc; ScopedReport R(Opts, Loc); - - if (!Pointer) - Diag(Loc, DL_Error, "%0 null pointer of type %1") + const char *Name; + const char *NullName = "null"; + const char *AlignmentName = "alignment"; + const char *ObjectSizeName = "object-size"; + + if (!Pointer) { + Name = NullName; + Diag(Loc, DL_Error, Name, "%0 null pointer of type %1") << TypeCheckKinds[Data->TypeCheckKind] << Data->Type; - else if (Data->Alignment && (Pointer & (Data->Alignment - 1))) - Diag(Loc, DL_Error, "%0 misaligned address %1 for type %3, " - "which requires %2 byte alignment") + } else if (Data->Alignment && (Pointer & (Data->Alignment - 1))) { + Name = AlignmentName; + Diag(Loc, DL_Error, Name, "%0 misaligned address %1 for type %3, " + "which requires %2 byte alignment") << TypeCheckKinds[Data->TypeCheckKind] << (void*)Pointer << Data->Alignment << Data->Type; - else - Diag(Loc, DL_Error, "%0 address %1 with insufficient space " - "for an object of type %2") + } else { + Name = ObjectSizeName; + Diag(Loc, DL_Error, Name, "%0 address %1 with insufficient space " + "for an object of type %2") << TypeCheckKinds[Data->TypeCheckKind] << (void*)Pointer << Data->Type; + } if (Pointer) - Diag(Pointer, DL_Note, "pointer points here"); + Diag(Pointer, DL_Note, Name, "pointer points here"); } void __ubsan::__ubsan_handle_type_mismatch(TypeMismatchData *Data, @@ -86,10 +96,14 @@ return; ScopedReport R(Opts, Loc); - - Diag(Loc, DL_Error, "%0 integer overflow: " - "%1 %2 %3 cannot be represented in type %4") - << (Data->Type.isSignedIntegerTy() ? "signed" : "unsigned") + const char *SignedName = "signed-integer-overflow"; + const char *UnsignedName = "unsigned-integer-overflow"; + bool IsSigned = Data->Type.isSignedIntegerTy(); + const char *Name = IsSigned ? SignedName : UnsignedName; + + Diag(Loc, DL_Error, Name, "%0 integer overflow: " + "%1 %2 %3 cannot be represented in type %4") + << (IsSigned ? "signed" : "unsigned") << Value(Data->Type, LHS) << Operator << RHS << Data->Type; } @@ -115,14 +129,18 @@ return; ScopedReport R(Opts, Loc); + const char *SignedName = "signed-integer-overflow"; + const char *UnsignedName = "unsigned-integer-overflow"; + bool IsSigned = Data->Type.isSignedIntegerTy(); + const char *Name = IsSigned ? SignedName : UnsignedName; - if (Data->Type.isSignedIntegerTy()) - Diag(Loc, DL_Error, + if (IsSigned) + Diag(Loc, DL_Error, Name, "negation of %0 cannot be represented in type %1; " "cast to an unsigned type to negate this value to itself") << Value(Data->Type, OldVal) << Data->Type; else - Diag(Loc, DL_Error, + Diag(Loc, DL_Error, Name, "negation of %0 cannot be represented in type %1") << Value(Data->Type, OldVal) << Data->Type; } @@ -146,15 +164,19 @@ return; ScopedReport R(Opts, Loc); + const char *IntegerName = "integer-divide-by-zero"; + const char *FloatName = "float-divide-by-zero"; + const char *MinusOneName = "signed-integer-overflow"; + const char *Name = Data->Type.isIntegerTy() ? IntegerName : FloatName; Value LHSVal(Data->Type, LHS); Value RHSVal(Data->Type, RHS); if (RHSVal.isMinusOne()) - Diag(Loc, DL_Error, + Diag(Loc, DL_Error, MinusOneName, "division of %0 by -1 cannot be represented in type %1") << LHSVal << Data->Type; else - Diag(Loc, DL_Error, "division by zero"); + Diag(Loc, DL_Error, Name, "division by zero"); } void __ubsan::__ubsan_handle_divrem_overflow(OverflowData *Data, @@ -178,19 +200,20 @@ return; ScopedReport R(Opts, Loc); + const char *Name = "shift"; Value LHSVal(Data->LHSType, LHS); Value RHSVal(Data->RHSType, RHS); if (RHSVal.isNegative()) - Diag(Loc, DL_Error, "shift exponent %0 is negative") << RHSVal; + Diag(Loc, DL_Error, Name, "shift exponent %0 is negative") << RHSVal; else if (RHSVal.getPositiveIntValue() >= Data->LHSType.getIntegerBitWidth()) - Diag(Loc, DL_Error, + Diag(Loc, DL_Error, Name, "shift exponent %0 is too large for %1-bit type %2") << RHSVal << Data->LHSType.getIntegerBitWidth() << Data->LHSType; else if (LHSVal.isNegative()) - Diag(Loc, DL_Error, "left shift of negative value %0") << LHSVal; + Diag(Loc, DL_Error, Name, "left shift of negative value %0") << LHSVal; else - Diag(Loc, DL_Error, + Diag(Loc, DL_Error, Name, "left shift of %0 by %1 places cannot be represented in type %2") << LHSVal << RHSVal << Data->LHSType; } @@ -217,9 +240,10 @@ return; ScopedReport R(Opts, Loc); + const char *Name = "bounds"; Value IndexVal(Data->IndexType, Index); - Diag(Loc, DL_Error, "index %0 out of bounds for type %1") + Diag(Loc, DL_Error, Name, "index %0 out of bounds for type %1") << IndexVal << Data->ArrayType; } @@ -238,7 +262,8 @@ static void handleBuiltinUnreachableImpl(UnreachableData *Data, ReportOptions Opts) { ScopedReport R(Opts, Data->Loc); - Diag(Data->Loc, DL_Error, "execution reached a __builtin_unreachable() call"); + const char *Name = "unreachable"; + Diag(Data->Loc, DL_Error, Name, "execution reached a __builtin_unreachable() call"); } void __ubsan::__ubsan_handle_builtin_unreachable(UnreachableData *Data) { @@ -249,7 +274,8 @@ static void handleMissingReturnImpl(UnreachableData *Data, ReportOptions Opts) { ScopedReport R(Opts, Data->Loc); - Diag(Data->Loc, DL_Error, + const char *Name = "return"; + Diag(Data->Loc, DL_Error, Name, "execution reached the end of a value-returning function " "without returning a value"); } @@ -267,9 +293,10 @@ return; ScopedReport R(Opts, Loc); + const char *Name = "vla-bound"; - Diag(Loc, DL_Error, "variable length array bound evaluates to " - "non-positive value %0") + Diag(Loc, DL_Error, Name, "variable length array bound evaluates to " + "non-positive value %0") << Value(Data->Type, Bound); } @@ -290,8 +317,9 @@ // TODO: Add deduplication once a SourceLocation is generated for this check. Location Loc = getCallerLocation(); ScopedReport R(Opts, Loc); + const char *Name = "float-cast-overflow"; - Diag(Loc, DL_Error, + Diag(Loc, DL_Error, Name, "value %0 is outside the range of representable values of type %2") << Value(Data->FromType, From) << Data->FromType << Data->ToType; } @@ -316,8 +344,13 @@ return; ScopedReport R(Opts, Loc); + const char *Name; + if (!strcmp(Data->Type.getTypeName(), "'bool'")) // XXX(mathstuf): Is there a better way to do this? + Name = "bool"; + else + Name = "enum"; - Diag(Loc, DL_Error, + Diag(Loc, DL_Error, Name, "load of value %0, which is not a valid value for type %1") << Value(Data->Type, Val) << Data->Type; } @@ -342,11 +375,12 @@ Location Loc = getFunctionLocation(Function, &FName); ScopedReport R(Opts, Loc); + const char *Name = "function"; - Diag(Data->Loc, DL_Error, + Diag(Data->Loc, DL_Error, Name, "call to function %0 through pointer to incorrect function type %1") << FName << Data->Type; - Diag(Loc, DL_Note, "%0 defined here") << FName; + Diag(Loc, DL_Note, Name, "%0 defined here") << FName; } void @@ -369,11 +403,12 @@ return; ScopedReport R(Opts, Loc); + const char *Name = "returns-nonnull-attribute"; - Diag(Loc, DL_Error, "null pointer returned from function declared to never " - "return null"); + Diag(Loc, DL_Error, Name, "null pointer returned from function declared to never " + "return null"); if (!Data->AttrLoc.isInvalid()) - Diag(Data->AttrLoc, DL_Note, "returns_nonnull attribute specified here"); + Diag(Data->AttrLoc, DL_Note, Name, "returns_nonnull attribute specified here"); } void __ubsan::__ubsan_handle_nonnull_return(NonNullReturnData *Data) { @@ -393,11 +428,12 @@ return; ScopedReport R(Opts, Loc); + const char *Name = "nonnull-attribute"; - Diag(Loc, DL_Error, "null pointer passed as argument %0, which is declared to " + Diag(Loc, DL_Error, Name, "null pointer passed as argument %0, which is declared to " "never be null") << Data->ArgIndex; if (!Data->AttrLoc.isInvalid()) - Diag(Data->AttrLoc, DL_Note, "nonnull attribute specified here"); + Diag(Data->AttrLoc, DL_Note, Name, "nonnull attribute specified here"); } void __ubsan::__ubsan_handle_nonnull_arg(NonNullArgData *Data) { Index: lib/ubsan/ubsan_handlers_cxx.cc =================================================================== --- lib/ubsan/ubsan_handlers_cxx.cc +++ lib/ubsan/ubsan_handlers_cxx.cc @@ -45,24 +45,25 @@ return; ScopedReport R(Opts, Loc); + const char *Name = "vptr"; - Diag(Loc, DL_Error, + Diag(Loc, DL_Error, Name, "%0 address %1 which does not point to an object of type %2") << TypeCheckKinds[Data->TypeCheckKind] << (void*)Pointer << Data->Type; // If possible, say what type it actually points to. if (!DTI.isValid()) - Diag(Pointer, DL_Note, "object has invalid vptr") + Diag(Pointer, DL_Note, Name, "object has invalid vptr") << MangledName(DTI.getMostDerivedTypeName()) << Range(Pointer, Pointer + sizeof(uptr), "invalid vptr"); else if (!DTI.getOffset()) - Diag(Pointer, DL_Note, "object is of type %0") + Diag(Pointer, DL_Note, Name, "object is of type %0") << MangledName(DTI.getMostDerivedTypeName()) << Range(Pointer, Pointer + sizeof(uptr), "vptr for %0"); else // FIXME: Find the type at the specified offset, and include that // in the note. - Diag(Pointer - DTI.getOffset(), DL_Note, + Diag(Pointer - DTI.getOffset(), DL_Note, Name, "object is base class subobject at offset %0 within object of type %1") << DTI.getOffset() << MangledName(DTI.getMostDerivedTypeName()) << MangledName(DTI.getSubobjectTypeName()) Index: test/ubsan/TestCases/Float/cast-overflow.cpp =================================================================== --- test/ubsan/TestCases/Float/cast-overflow.cpp +++ test/ubsan/TestCases/Float/cast-overflow.cpp @@ -79,31 +79,31 @@ case '0': // Note that values between 0x7ffffe00 and 0x80000000 may or may not // successfully round-trip, depending on the rounding mode. - // CHECK-0: runtime error: value 2.14748{{.*}} is outside the range of representable values of type 'int' + // CHECK-0: UndefinedBehaviorSanitizer float-cast-overflow error: value 2.14748{{.*}} is outside the range of representable values of type 'int' return MaxFloatRepresentableAsInt + 0x80; case '1': - // CHECK-1: runtime error: value -2.14748{{.*}} is outside the range of representable values of type 'int' + // CHECK-1: UndefinedBehaviorSanitizer float-cast-overflow error: value -2.14748{{.*}} is outside the range of representable values of type 'int' return MinFloatRepresentableAsInt - 0x100; case '2': { - // CHECK-2: runtime error: value -1 is outside the range of representable values of type 'unsigned int' + // CHECK-2: UndefinedBehaviorSanitizer float-cast-overflow error: value -1 is outside the range of representable values of type 'unsigned int' volatile float f = -1.0; volatile unsigned u = (unsigned)f; return 0; } case '3': - // CHECK-3: runtime error: value 4.2949{{.*}} is outside the range of representable values of type 'unsigned int' + // CHECK-3: UndefinedBehaviorSanitizer float-cast-overflow error: value 4.2949{{.*}} is outside the range of representable values of type 'unsigned int' return (unsigned)(MaxFloatRepresentableAsUInt + 0x100); case '4': - // CHECK-4: runtime error: value {{.*}} is outside the range of representable values of type 'int' + // CHECK-4: UndefinedBehaviorSanitizer float-cast-overflow error: value {{.*}} is outside the range of representable values of type 'int' return Inf; case '5': - // CHECK-5: runtime error: value {{.*}} is outside the range of representable values of type 'int' + // CHECK-5: UndefinedBehaviorSanitizer float-cast-overflow error: value {{.*}} is outside the range of representable values of type 'int' return NaN; // 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}} + // CHECK-6: {{UndefinedBehaviorSanitizer float-cast-overflow error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'|__int128 not supported}} #ifdef __SIZEOF_INT128__ return (float)(FloatMaxAsUInt128 + 1); #else @@ -113,16 +113,16 @@ // FIXME: The backend cannot lower __fp16 operations on x86 yet. //case '7': // (__fp16)65504; // ok - // // CHECK-7: runtime error: value 65505 is outside the range of representable values of type '__fp16' + // // CHECK-7: UndefinedBehaviorSanitizer float-cast-overflow 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: runtime error: value 1e+39 is outside the range of representable values of type 'float' + // CHECK-8: UndefinedBehaviorSanitizer float-cast-overflow error: value 1e+39 is outside the range of representable values of type 'float' return (float)1e39; case '9': volatile long double ld = 300.0; - // CHECK-9: runtime error: value 300 is outside the range of representable values of type 'char' + // CHECK-9: UndefinedBehaviorSanitizer float-cast-overflow error: value 300 is outside the range of representable values of type 'char' char c = ld; return c; } Index: test/ubsan/TestCases/Integer/add-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/add-overflow.cpp +++ test/ubsan/TestCases/Integer/add-overflow.cpp @@ -13,7 +13,7 @@ #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' + // CHECK-ADD_I32: add-overflow.cpp:[[@LINE-1]]:5: UndefinedBehaviorSanitizer signed-integer-overflow error: signed integer overflow: 305419896 + 2023406814 cannot be represented in type 'int' #endif #ifdef ADD_I64 Index: test/ubsan/TestCases/Integer/div-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/div-overflow.cpp +++ test/ubsan/TestCases/Integer/div-overflow.cpp @@ -5,6 +5,6 @@ int main() { unsigned(0x80000000) / -1; - // CHECK: div-overflow.cpp:9:23: runtime error: division of -2147483648 by -1 cannot be represented in type 'int' + // CHECK: div-overflow.cpp:9:23: UndefinedBehaviorSanitizer signed-integer-overflow error: division of -2147483648 by -1 cannot be represented in type 'int' int32_t(0x80000000) / -1; } Index: test/ubsan/TestCases/Integer/div-zero.cpp =================================================================== --- test/ubsan/TestCases/Integer/div-zero.cpp +++ test/ubsan/TestCases/Integer/div-zero.cpp @@ -1,7 +1,7 @@ -// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND=0 %s -o %t && %run %t 2>&1 | FileCheck %s -// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND=1U %s -o %t && %run %t 2>&1 | FileCheck %s -// 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 +// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND=0 %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECKI +// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND=1U %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECKI +// RUN: %clangxx -fsanitize=float-divide-by-zero -DDIVIDEND=1.5 %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECKF +// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND='intmax(123)' %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECKI #ifdef __SIZEOF_INT128__ typedef __int128 intmax; @@ -10,6 +10,7 @@ #endif int main() { - // CHECK: div-zero.cpp:[[@LINE+1]]:12: runtime error: division by zero + // CHECKI: div-zero.cpp:[[@LINE+2]]:12: UndefinedBehaviorSanitizer integer-divide-by-zero error: division by zero + // CHECKF: div-zero.cpp:[[@LINE+1]]:12: UndefinedBehaviorSanitizer float-divide-by-zero error: division by zero DIVIDEND / 0; } Index: test/ubsan/TestCases/Integer/incdec-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/incdec-overflow.cpp +++ test/ubsan/TestCases/Integer/incdec-overflow.cpp @@ -10,7 +10,7 @@ n++; n++; int m = -n - 1; - // CHECK: incdec-overflow.cpp:15:3: runtime error: signed integer overflow: [[MINUS:-?]]214748364 + // CHECK: incdec-overflow.cpp:15:3: UndefinedBehaviorSanitizer signed-integer-overflow error: signed integer overflow: [[MINUS:-?]]214748364 // CHECK: + [[MINUS]]1 cannot be represented in type 'int' OP; } Index: test/ubsan/TestCases/Integer/mul-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/mul-overflow.cpp +++ test/ubsan/TestCases/Integer/mul-overflow.cpp @@ -9,6 +9,6 @@ (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' + // CHECK: mul-overflow.cpp:13:27: UndefinedBehaviorSanitizer signed-integer-overflow error: signed integer overflow: 65535 * 32769 cannot be represented in type 'int' (void)(uint16_t(0xffff) * uint16_t(0x8001)); } Index: test/ubsan/TestCases/Integer/negate-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/negate-overflow.cpp +++ test/ubsan/TestCases/Integer/negate-overflow.cpp @@ -2,11 +2,11 @@ // RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %run %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' + // CHECKS-NOT: UndefinedBehaviorSanitizer signed-integer-overflow + // CHECKU: negate-overflow.cpp:[[@LINE+2]]:3: UndefinedBehaviorSanitizer unsigned-integer-overflow 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 + // CHECKS: negate-overflow.cpp:[[@LINE+2]]:10: UndefinedBehaviorSanitizer signed-integer-overflow error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself + // CHECKU-NOT: UndefinedBehaviorSanitizer unsigned-integer-overflow return -(-0x7fffffff - 1); } Index: test/ubsan/TestCases/Integer/no-recover.cpp =================================================================== --- test/ubsan/TestCases/Integer/no-recover.cpp +++ test/ubsan/TestCases/Integer/no-recover.cpp @@ -8,15 +8,15 @@ // 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 + // RECOVER-NOT: UndefinedBehaviorSanitizer unsigned-integer-overflow + // ABORT-NOT: UndefinedBehaviorSanitizer unsigned-integer-overflow 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' + // RECOVER: no-recover.cpp:[[@LINE-1]]:5: UndefinedBehaviorSanitizer unsigned-integer-overflow error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'unsigned int' + // ABORT: no-recover.cpp:[[@LINE-2]]:5: UndefinedBehaviorSanitizer unsigned-integer-overflow 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 + // ABORT-NOT: UndefinedBehaviorSanitizer unsigned-integer-overflow } Index: test/ubsan/TestCases/Integer/shift.cpp =================================================================== --- test/ubsan/TestCases/Integer/shift.cpp +++ test/ubsan/TestCases/Integer/shift.cpp @@ -20,18 +20,18 @@ b <<= 1; // still ok, unsigned #ifdef LSH_OVERFLOW - // CHECK-LSH_OVERFLOW: shift.cpp:24:5: runtime error: left shift of negative value -2147483648 + // CHECK-LSH_OVERFLOW: shift.cpp:24:5: UndefinedBehaviorSanitizer shift 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 + // CHECK-TOO_LOW: shift.cpp:29:5: UndefinedBehaviorSanitizer shift 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' + // CHECK-TOO_HIGH: shift.cpp:35:5: UndefinedBehaviorSanitizer shift error: shift exponent 32 is too large for 32-bit type 'int' a OP 32; #endif } Index: test/ubsan/TestCases/Integer/sub-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/sub-overflow.cpp +++ test/ubsan/TestCases/Integer/sub-overflow.cpp @@ -12,7 +12,7 @@ #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' + // CHECK-SUB_I32: sub-overflow.cpp:[[@LINE-1]]:22: UndefinedBehaviorSanitizer signed-integer-overflow error: signed integer overflow: -2 - 2147483647 cannot be represented in type 'int' #endif #ifdef SUB_I64 Index: test/ubsan/TestCases/Integer/uadd-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/uadd-overflow.cpp +++ test/ubsan/TestCases/Integer/uadd-overflow.cpp @@ -13,7 +13,7 @@ #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' + // CHECK-ADD_I32: uadd-overflow.cpp:[[@LINE-1]]:5: UndefinedBehaviorSanitizer unsigned-integer-overflow error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'unsigned int' #endif #ifdef ADD_I64 Index: test/ubsan/TestCases/Integer/uincdec-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/uincdec-overflow.cpp +++ test/ubsan/TestCases/Integer/uincdec-overflow.cpp @@ -10,7 +10,7 @@ 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' + // CHECK-INC: uincdec-overflow.cpp:15:3: UndefinedBehaviorSanitizer unsigned-integer-overflow error: unsigned integer overflow: 4294967295 + 1 cannot be represented in type 'unsigned int' + // CHECK-DEC: uincdec-overflow.cpp:15:3: UndefinedBehaviorSanitizer unsigned-integer-overflow error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int' OP; } Index: test/ubsan/TestCases/Integer/umul-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/umul-overflow.cpp +++ test/ubsan/TestCases/Integer/umul-overflow.cpp @@ -13,7 +13,7 @@ (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' + // CHECK: umul-overflow.cpp:15:31: UndefinedBehaviorSanitizer unsigned-integer-overflow error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int' return 0; } Index: test/ubsan/TestCases/Integer/usub-overflow.cpp =================================================================== --- test/ubsan/TestCases/Integer/usub-overflow.cpp +++ test/ubsan/TestCases/Integer/usub-overflow.cpp @@ -12,7 +12,7 @@ #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' + // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: UndefinedBehaviorSanitizer unsigned-integer-overflow error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int' #endif #ifdef SUB_I64 Index: test/ubsan/TestCases/Misc/bool.cpp =================================================================== --- test/ubsan/TestCases/Misc/bool.cpp +++ test/ubsan/TestCases/Misc/bool.cpp @@ -5,6 +5,6 @@ int main(int argc, char **argv) { bool *p = (bool*)&NotABool; - // CHECK: bool.cpp:9:10: runtime error: load of value 123, which is not a valid value for type 'bool' + // CHECK: bool.cpp:9:10: UndefinedBehaviorSanitizer bool error: load of value 123, which is not a valid value for type 'bool' return *p; } Index: test/ubsan/TestCases/Misc/bounds.cpp =================================================================== --- test/ubsan/TestCases/Misc/bounds.cpp +++ test/ubsan/TestCases/Misc/bounds.cpp @@ -9,7 +9,7 @@ int arr[2][3][4] = {}; return arr[argv[1][0] - '0'][argv[2][0] - '0'][argv[3][0] - '0']; - // CHECK-A-2: bounds.cpp:[[@LINE-1]]:10: runtime error: index 2 out of bounds for type 'int [2][3][4]' - // CHECK-B-3: bounds.cpp:[[@LINE-2]]:10: runtime error: index 3 out of bounds for type 'int [3][4]' - // CHECK-C-4: bounds.cpp:[[@LINE-3]]:10: runtime error: index 4 out of bounds for type 'int [4]' + // CHECK-A-2: bounds.cpp:[[@LINE-1]]:10: UndefinedBehaviorSanitizer bounds error: index 2 out of bounds for type 'int [2][3][4]' + // CHECK-B-3: bounds.cpp:[[@LINE-2]]:10: UndefinedBehaviorSanitizer bounds error: index 3 out of bounds for type 'int [3][4]' + // CHECK-C-4: bounds.cpp:[[@LINE-3]]:10: UndefinedBehaviorSanitizer bounds error: index 4 out of bounds for type 'int [4]' } Index: test/ubsan/TestCases/Misc/deduplication.cpp =================================================================== --- test/ubsan/TestCases/Misc/deduplication.cpp +++ test/ubsan/TestCases/Misc/deduplication.cpp @@ -12,9 +12,9 @@ // CHECK: Start fprintf(stderr, "Start\n"); - // CHECK: runtime error - // CHECK-NOT: runtime error - // CHECK-NOT: runtime error + // CHECK: UndefinedBehaviorSanitizer + // CHECK-NOT: UndefinedBehaviorSanitizer + // CHECK-NOT: UndefinedBehaviorSanitizer overflow(); overflow(); overflow(); Index: test/ubsan/TestCases/Misc/enum.cpp =================================================================== --- test/ubsan/TestCases/Misc/enum.cpp +++ test/ubsan/TestCases/Misc/enum.cpp @@ -10,8 +10,8 @@ for (unsigned char *p = (unsigned char*)&e; p != (unsigned char*)(&e + 1); ++p) *p = 0xff; - // CHECK-PLAIN: error: load of value 4294967295, which is not a valid value for type 'enum E' + // CHECK-PLAIN: UndefinedBehaviorSanitizer enum error: load of value 4294967295, which is not a valid value for type 'enum E' // FIXME: Support marshalling and display of enum class values. - // CHECK-BOOL: error: load of value , which is not a valid value for type 'enum E' + // CHECK-BOOL: UndefinedBehaviorSanitizer enum error: load of value , which is not a valid value for type 'enum E' return (int)e != -1; } Index: test/ubsan/TestCases/Misc/missing_return.cpp =================================================================== --- test/ubsan/TestCases/Misc/missing_return.cpp +++ test/ubsan/TestCases/Misc/missing_return.cpp @@ -2,7 +2,7 @@ // RUN: not %run %t 2>&1 | FileCheck %s // RUN: UBSAN_OPTIONS=print_stacktrace=1 not %run %t 2>&1 | FileCheck %s --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 +// CHECK: missing_return.cpp:[[@LINE+1]]:5: UndefinedBehaviorSanitizer return error: execution reached the end of a value-returning function without returning a value int f() { // Slow stack unwinding is disabled on Darwin for now, see // https://code.google.com/p/address-sanitizer/issues/detail?id=137 Index: test/ubsan/TestCases/Misc/nonnull-arg.cpp =================================================================== --- test/ubsan/TestCases/Misc/nonnull-arg.cpp +++ test/ubsan/TestCases/Misc/nonnull-arg.cpp @@ -39,20 +39,20 @@ switch (argv[1][1]) { case 'c': return C(0x0, arg).value(); - // CTOR: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:21: runtime error: null pointer passed as argument 2, which is declared to never be null - // CTOR-NEXT: {{.*}}nonnull-arg.cpp:16:31: note: nonnull attribute specified here + // CTOR: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:21: UndefinedBehaviorSanitizer nonnull-attribute error: null pointer passed as argument 2, which is declared to never be null + // CTOR-NEXT: {{.*}}nonnull-arg.cpp:16:31: UndefinedBehaviorSanitizer nonnull-attribute note: nonnull attribute specified here case 'm': return C(0x0, &local).method(arg, 0x0); - // METHOD: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:36: runtime error: null pointer passed as argument 1, which is declared to never be null - // METHOD-NEXT: {{.*}}nonnull-arg.cpp:19:54: note: nonnull attribute specified here + // METHOD: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:36: UndefinedBehaviorSanitizer nonnull-attribute error: null pointer passed as argument 1, which is declared to never be null + // METHOD-NEXT: {{.*}}nonnull-arg.cpp:19:54: UndefinedBehaviorSanitizer nonnull-attribute note: nonnull attribute specified here case 'f': return func(arg); - // FUNC: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:19: runtime error: null pointer passed as argument 1, which is declared to never be null - // FUNC-NEXT: {{.*}}nonnull-arg.cpp:24:16: note: nonnull attribute specified here + // FUNC: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:19: UndefinedBehaviorSanitizer nonnull-attribute error: null pointer passed as argument 1, which is declared to never be null + // FUNC-NEXT: {{.*}}nonnull-arg.cpp:24:16: UndefinedBehaviorSanitizer nonnull-attribute note: nonnull attribute specified here case 'v': return variadic(42, arg); - // VARIADIC: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:27: runtime error: null pointer passed as argument 2, which is declared to never be null - // VARIADIC-NEXT: {{.*}}nonnull-arg.cpp:27:16: note: nonnull attribute specified here + // VARIADIC: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:27: UndefinedBehaviorSanitizer nonnull-attribute error: null pointer passed as argument 2, which is declared to never be null + // VARIADIC-NEXT: {{.*}}nonnull-arg.cpp:27:16: UndefinedBehaviorSanitizer nonnull-attribute note: nonnull attribute specified here } return 0; } Index: test/ubsan/TestCases/Misc/nonnull.cpp =================================================================== --- test/ubsan/TestCases/Misc/nonnull.cpp +++ test/ubsan/TestCases/Misc/nonnull.cpp @@ -6,8 +6,8 @@ char *foo(char *a) { return a; - // CHECK: nonnull.cpp:[[@LINE+2]]:1: runtime error: null pointer returned from function declared to never return null - // CHECK-NEXT: nonnull.cpp:[[@LINE-5]]:16: note: returns_nonnull attribute specified here + // CHECK: nonnull.cpp:[[@LINE+2]]:1: UndefinedBehaviorSanitizer returns-nonnull-attribute error: null pointer returned from function declared to never return null + // CHECK-NEXT: nonnull.cpp:[[@LINE-5]]:16: UndefinedBehaviorSanitizer returns-nonnull-attribute note: returns_nonnull attribute specified here } int main(int argc, char **argv) { Index: test/ubsan/TestCases/Misc/unreachable.cpp =================================================================== --- test/ubsan/TestCases/Misc/unreachable.cpp +++ test/ubsan/TestCases/Misc/unreachable.cpp @@ -1,6 +1,6 @@ // RUN: %clangxx -fsanitize=unreachable %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s int main(int, char **argv) { - // CHECK: unreachable.cpp:5:3: runtime error: execution reached a __builtin_unreachable() call + // CHECK: unreachable.cpp:5:3: UndefinedBehaviorSanitizer unreachable error: execution reached a __builtin_unreachable() call __builtin_unreachable(); } Index: test/ubsan/TestCases/Misc/vla.c =================================================================== --- test/ubsan/TestCases/Misc/vla.c +++ test/ubsan/TestCases/Misc/vla.c @@ -4,8 +4,8 @@ // RUN: %run %t a b int main(int argc, char **argv) { - // 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 + // CHECK-MINUS-ONE: vla.c:9:11: UndefinedBehaviorSanitizer vla-bound error: variable length array bound evaluates to non-positive value -1 + // CHECK-ZERO: vla.c:9:11: UndefinedBehaviorSanitizer vla-bound error: variable length array bound evaluates to non-positive value 0 int arr[argc - 2]; return 0; } Index: test/ubsan/TestCases/TypeCheck/Function/function.cpp =================================================================== --- test/ubsan/TestCases/TypeCheck/Function/function.cpp +++ test/ubsan/TestCases/TypeCheck/Function/function.cpp @@ -13,12 +13,12 @@ void g(int x) {} int main(void) { - // CHECK: runtime error: call to function f() through pointer to incorrect function type 'void (*)(int)' - // CHECK-NEXT: function.cpp:11: note: f() defined here - // NOSYM: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)' - // NOSYM-NEXT: ({{.*}}+0x{{.*}}): note: (unknown) defined here + // CHECK: UndefinedBehaviorSanitizer function error: call to function f() through pointer to incorrect function type 'void (*)(int)' + // CHECK-NEXT: function.cpp:11: UndefinedBehaviorSanitizer function note: f() defined here + // NOSYM: UndefinedBehaviorSanitizer function error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)' + // NOSYM-NEXT: ({{.*}}+0x{{.*}}): UndefinedBehaviorSanitizer function note: (unknown) defined here reinterpret_cast(reinterpret_cast(f))(42); - // CHECK-NOT: runtime error: call to function g + // CHECK-NOT: UndefinedBehaviorSanitizer function error: call to function g reinterpret_cast(reinterpret_cast(g))(42); } Index: test/ubsan/TestCases/TypeCheck/misaligned.cpp =================================================================== --- test/ubsan/TestCases/TypeCheck/misaligned.cpp +++ test/ubsan/TestCases/TypeCheck/misaligned.cpp @@ -39,8 +39,8 @@ 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-NEXT: [[PTR]]: note: pointer points here + // CHECK-LOAD: misaligned.cpp:[[@LINE+4]]:12: UndefinedBehaviorSanitizer alignment error: load of misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment + // CHECK-LOAD-NEXT: [[PTR]]: UndefinedBehaviorSanitizer alignment note: pointer points here // CHECK-LOAD-NEXT: {{^ 00 00 00 01 02 03 04 05}} // CHECK-LOAD-NEXT: {{^ \^}} return *p && 0; @@ -51,45 +51,45 @@ // 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-NEXT: [[PTR]]: note: pointer points here + // CHECK-STORE: misaligned.cpp:[[@LINE+4]]:5: UndefinedBehaviorSanitizer alignment error: store to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment + // CHECK-STORE-NEXT: [[PTR]]: UndefinedBehaviorSanitizer alignment note: pointer points here // CHECK-STORE-NEXT: {{^ 00 00 00 01 02 03 04 05}} // CHECK-STORE-NEXT: {{^ \^}} *p = 1; 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-NEXT: [[PTR]]: note: pointer points here + // CHECK-REFERENCE: misaligned.cpp:[[@LINE+4]]:15: UndefinedBehaviorSanitizer alignment error: reference binding to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment + // CHECK-REFERENCE-NEXT: [[PTR]]: UndefinedBehaviorSanitizer alignment note: pointer points here // CHECK-REFERENCE-NEXT: {{^ 00 00 00 01 02 03 04 05}} // CHECK-REFERENCE-NEXT: {{^ \^}} {int &r = *p;} 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-NEXT: [[PTR]]: note: pointer points here + // CHECK-MEMBER: misaligned.cpp:[[@LINE+4]]:15: UndefinedBehaviorSanitizer alignment error: member access within misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment + // CHECK-MEMBER-NEXT: [[PTR]]: UndefinedBehaviorSanitizer alignment 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-NEXT: [[PTR]]: note: pointer points here + // CHECK-MEMFUN: misaligned.cpp:[[@LINE+4]]:12: UndefinedBehaviorSanitizer alignment error: member call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment + // CHECK-MEMFUN-NEXT: [[PTR]]: UndefinedBehaviorSanitizer alignment 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]]:5: 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: misaligned.cpp:[[@LINE+4]]:5: UndefinedBehaviorSanitizer alignment error: constructor call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment + // CHECK-NEW-NEXT: [[PTR]]: UndefinedBehaviorSanitizer alignment 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-NEXT: [[PTR]]: note: pointer points here + // CHECK-UPCAST: misaligned.cpp:[[@LINE+4]]:17: UndefinedBehaviorSanitizer alignment error: upcast of misaligned address [[PTR:0x[0-9a-f]*]] for type 'T', which requires 4 byte alignment + // CHECK-UPCAST-NEXT: [[PTR]]: UndefinedBehaviorSanitizer alignment note: pointer points here // CHECK-UPCAST-NEXT: {{^ 00 00 00 01 02 03 04 05}} // CHECK-UPCAST-NEXT: {{^ \^}} S *s2 = (S*)t; @@ -97,8 +97,8 @@ } case 'w': - // CHECK-WILD: misaligned.cpp:[[@LINE+3]]:35: runtime error: member access within misaligned address 0x000000000123 for type 'S', which requires 4 byte alignment - // CHECK-WILD-NEXT: 0x000000000123: note: pointer points here + // CHECK-WILD: misaligned.cpp:[[@LINE+3]]:35: UndefinedBehaviorSanitizer alignment error: member access within misaligned address 0x000000000123 for type 'S', which requires 4 byte alignment + // CHECK-WILD-NEXT: 0x000000000123: UndefinedBehaviorSanitizer alignment note: pointer points here // CHECK-WILD-NEXT: return static_cast(wild)->k; } Index: test/ubsan/TestCases/TypeCheck/null.cpp =================================================================== --- test/ubsan/TestCases/TypeCheck/null.cpp +++ test/ubsan/TestCases/TypeCheck/null.cpp @@ -18,21 +18,21 @@ switch (argv[1][0]) { case 'l': - // CHECK-LOAD: null.cpp:22:12: runtime error: load of null pointer of type 'int' + // CHECK-LOAD: null.cpp:22:12: UndefinedBehaviorSanitizer null error: load of null pointer of type 'int' return *p; case 's': - // CHECK-STORE: null.cpp:25:5: runtime error: store to null pointer of type 'int' + // CHECK-STORE: null.cpp:25:5: UndefinedBehaviorSanitizer null error: store to null pointer of type 'int' *p = 1; break; case 'r': - // CHECK-REFERENCE: null.cpp:29:15: runtime error: reference binding to null pointer of type 'int' + // CHECK-REFERENCE: null.cpp:29:15: UndefinedBehaviorSanitizer null error: reference binding to null pointer of type 'int' {int &r = *p;} break; case 'm': - // CHECK-MEMBER: null.cpp:33:15: runtime error: member access within null pointer of type 'S' + // CHECK-MEMBER: null.cpp:33:15: UndefinedBehaviorSanitizer null error: member access within null pointer of type 'S' return s->k; case 'f': - // CHECK-MEMFUN: null.cpp:36:12: runtime error: member call on null pointer of type 'S' + // CHECK-MEMFUN: null.cpp:36:12: UndefinedBehaviorSanitizer null error: member call on null pointer of type 'S' return s->f(); } } Index: test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp =================================================================== --- test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp +++ test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp @@ -13,7 +13,7 @@ Foo foo; T *t = (T*)&foo; S *s = t; - // CHECK: vptr-virtual-base.cpp:[[@LINE-1]]:10: runtime error: cast to virtual base of address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' - // CHECK-NEXT: [[PTR]]: note: object is of type 'Foo' + // CHECK: vptr-virtual-base.cpp:[[@LINE-1]]:10: UndefinedBehaviorSanitizer vptr error: cast to virtual base of address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' + // CHECK-NEXT: [[PTR]]: UndefinedBehaviorSanitizer vptr note: object is of type 'Foo' return s->f(); } Index: test/ubsan/TestCases/TypeCheck/vptr.cpp =================================================================== --- test/ubsan/TestCases/TypeCheck/vptr.cpp +++ test/ubsan/TestCases/TypeCheck/vptr.cpp @@ -110,8 +110,8 @@ for (int i = 0; i < 2; i++) { // Check that the first iteration ("S") succeeds, while the second ("V") fails. p = reinterpret_cast((i == 0) ? new S : new V); - // CHECK-LOC-SUPPRESS: vptr.cpp:[[@LINE+5]]:7: runtime error: member call on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' - // CHECK-LOC-SUPPRESS-NEXT: [[PTR]]: note: object is of type 'V' + // CHECK-LOC-SUPPRESS: vptr.cpp:[[@LINE+5]]:7: UndefinedBehaviorSanitizer vptr error: member call on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' + // CHECK-LOC-SUPPRESS-NEXT: [[PTR]]: UndefinedBehaviorSanitizer vptr note: object is of type 'V' // CHECK-LOC-SUPPRESS-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. }} // CHECK-LOC-SUPPRESS-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}} // CHECK-LOC-SUPPRESS-NEXT: {{^ vptr for 'V'}} @@ -120,24 +120,24 @@ return 0; case 'm': - // CHECK-MEMBER: vptr.cpp:[[@LINE+6]]:15: runtime error: member access within address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' - // CHECK-MEMBER-NEXT: [[PTR]]: note: object is of type [[DYN_TYPE:'S'|'U']] + // CHECK-MEMBER: vptr.cpp:[[@LINE+6]]:15: UndefinedBehaviorSanitizer vptr error: member access within address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' + // CHECK-MEMBER-NEXT: [[PTR]]: UndefinedBehaviorSanitizer vptr note: object is of type [[DYN_TYPE:'S'|'U']] // CHECK-MEMBER-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. }} // CHECK-MEMBER-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}} // CHECK-MEMBER-NEXT: {{^ vptr for}} [[DYN_TYPE]] // CHECK-MEMBER-NEXT: #0 {{.*}} in access_p{{.*}}vptr.cpp:[[@LINE+1]] return p->b; - // CHECK-NULL-MEMBER: vptr.cpp:[[@LINE-2]]:15: runtime error: member access within address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' - // CHECK-NULL-MEMBER-NEXT: [[PTR]]: note: object has invalid vptr + // CHECK-NULL-MEMBER: vptr.cpp:[[@LINE-2]]:15: UndefinedBehaviorSanitizer vptr error: member access within address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' + // CHECK-NULL-MEMBER-NEXT: [[PTR]]: UndefinedBehaviorSanitizer vptr note: object has invalid vptr // CHECK-NULL-MEMBER-NEXT: {{^ ?.. .. .. .. ?00 00 00 00 ?00 00 00 00 ?}} // CHECK-NULL-MEMBER-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}} // CHECK-NULL-MEMBER-NEXT: {{^ invalid vptr}} // CHECK-NULL-MEMBER-NEXT: #0 {{.*}} in access_p{{.*}}vptr.cpp:[[@LINE-7]] case 'f': - // CHECK-MEMFUN: vptr.cpp:[[@LINE+6]]:12: runtime error: member call on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' - // CHECK-MEMFUN-NEXT: [[PTR]]: note: object is of type [[DYN_TYPE:'S'|'U']] + // CHECK-MEMFUN: vptr.cpp:[[@LINE+6]]:12: UndefinedBehaviorSanitizer vptr error: member call on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' + // CHECK-MEMFUN-NEXT: [[PTR]]: UndefinedBehaviorSanitizer vptr note: object is of type [[DYN_TYPE:'S'|'U']] // CHECK-MEMFUN-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. }} // CHECK-MEMFUN-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}} // CHECK-MEMFUN-NEXT: {{^ vptr for}} [[DYN_TYPE]] @@ -145,8 +145,8 @@ return p->g(); case 'o': - // CHECK-OFFSET: vptr.cpp:[[@LINE+6]]:12: runtime error: member call on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'U' - // CHECK-OFFSET-NEXT: 0x{{[0-9a-f]*}}: note: object is base class subobject at offset {{8|16}} within object of type [[DYN_TYPE:'U']] + // CHECK-OFFSET: vptr.cpp:[[@LINE+6]]:12: UndefinedBehaviorSanitizer vptr error: member call on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'U' + // CHECK-OFFSET-NEXT: 0x{{[0-9a-f]*}}: UndefinedBehaviorSanitizer vptr note: object is base class subobject at offset {{8|16}} within object of type [[DYN_TYPE:'U']] // CHECK-OFFSET-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. }} // CHECK-OFFSET-NEXT: {{^ \^ ( ~~~~~~~~~~~~)?~~~~~~~~~~~ *$}} // CHECK-OFFSET-NEXT: {{^ ( )?vptr for}} 'T' base class of [[DYN_TYPE]] @@ -154,8 +154,8 @@ return reinterpret_cast(p)->v() - 2; case 'c': - // CHECK-DOWNCAST: vptr.cpp:[[@LINE+6]]:5: runtime error: downcast of address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' - // CHECK-DOWNCAST-NEXT: [[PTR]]: note: object is of type [[DYN_TYPE:'S'|'U']] + // CHECK-DOWNCAST: vptr.cpp:[[@LINE+6]]:5: UndefinedBehaviorSanitizer vptr error: downcast of address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T' + // CHECK-DOWNCAST-NEXT: [[PTR]]: UndefinedBehaviorSanitizer vptr note: object is of type [[DYN_TYPE:'S'|'U']] // CHECK-DOWNCAST-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. }} // CHECK-DOWNCAST-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}} // CHECK-DOWNCAST-NEXT: {{^ vptr for}} [[DYN_TYPE]]