[clang] [Clang] [CodeGen] UBSan Trap Reasons (PR #145967)
Dan Liew via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 30 16:52:41 PDT 2025
================
@@ -85,6 +85,94 @@ enum VariableTypeDescriptorKind : uint16_t {
// Miscellaneous Helper Methods
//===--------------------------------------------------------------------===//
+static llvm::StringRef GetUBSanTrapForHandler(SanitizerHandler ID) {
+ switch (ID) {
+ case SanitizerHandler::AddOverflow:
+ return "Signed integer addition overflowed";
+
+ case SanitizerHandler::BuiltinUnreachable:
+ return "_builtin_unreachable(), execution reached an unreachable program "
+ "point";
+
+ case SanitizerHandler::CFICheckFail:
+ return "Control flow integrity check failed";
+
+ case SanitizerHandler::DivremOverflow:
+ return "Signed integer divide or remainder overflowed";
+
+ case SanitizerHandler::DynamicTypeCacheMiss:
+ return "Dynamic-type cache miss";
+
+ case SanitizerHandler::FloatCastOverflow:
+ return "Floating-point to integer conversion overflowed";
+
+ case SanitizerHandler::FunctionTypeMismatch:
+ return "Function called with mismatched signature";
+
+ case SanitizerHandler::ImplicitConversion:
+ return "Implicit integer conversion overflowed or lost data";
+
+ case SanitizerHandler::InvalidBuiltin:
+ return "Invalid use of builtin function";
+
+ case SanitizerHandler::InvalidObjCCast:
+ return "Invalid Objective-C cast";
+
+ case SanitizerHandler::LoadInvalidValue:
+ return "Loaded an invalid or uninitialized value for the type";
+
+ case SanitizerHandler::MissingReturn:
+ return "Execution reached the end of a value-returning function without "
+ "returning a value";
+
+ case SanitizerHandler::MulOverflow:
+ return "Signed integer multiplication overflowed";
+
+ case SanitizerHandler::NegateOverflow:
+ return "Signed integer negation overflowed";
+
+ case SanitizerHandler::NullabilityArg:
+ return "Passing null as an argument which is annotated with "
+ "_Nonnull";
+
+ case SanitizerHandler::NullabilityReturn:
+ return "Returning null from a function with a return type annotated with "
+ "_Nonnull";
+
+ case SanitizerHandler::NonnullArg:
+ return "Passing null pointer as an argument which is declared to never be "
+ "null";
+
+ case SanitizerHandler::NonnullReturn:
+ return "Returning null pointer from a function which is declared to never "
+ "return null";
+
+ case SanitizerHandler::OutOfBounds:
+ return "Array index out of bounds";
+
+ case SanitizerHandler::PointerOverflow:
+ return "Pointer arithmetic overflowed bounds";
+
+ case SanitizerHandler::ShiftOutOfBounds:
+ return "Shift exponent is too large for the type";
+
+ case SanitizerHandler::SubOverflow:
+ return "Signed integer subtraction overflowed";
+
+ case SanitizerHandler::TypeMismatch:
+ return "Type mismatch in operation";
+
+ case SanitizerHandler::AlignmentAssumption:
+ return "Alignment assumption violated";
+
+ case SanitizerHandler::VLABoundNotPositive:
+ return "Variable length array bound evaluates to non-positive value";
+
+ case SanitizerHandler::BoundsSafety:
----------------
delcypher wrote:
Yes we should do that
https://github.com/llvm/llvm-project/pull/145967
More information about the cfe-commits
mailing list