[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)
Dan Liew via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 23 07:29:16 PDT 2025
================
@@ -85,6 +85,92 @@ enum VariableTypeDescriptorKind : uint16_t {
// Miscellaneous Helper Methods
//===--------------------------------------------------------------------===//
+static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) {
+ switch (ID) {
+ case SanitizerHandler::AddOverflow:
+ return "Signed integer addition overflowed.";
+
+ case SanitizerHandler::BuiltinUnreachable:
+ return "_builtin_unreachable() executed.";
+
+ 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";
+
+ case SanitizerHandler::MissingReturn:
+ return "Non-void function fell off end without return";
+
+ case SanitizerHandler::MulOverflow:
+ return "Signed integer multiplication overflowed";
+
+ case SanitizerHandler::NegateOverflow:
+ return "Signed integer negation overflowed";
+
+ case SanitizerHandler::NullabilityArg:
+ return "Passing null as a function parameter 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 as a function parameter which is declared to never be "
+ "null";
+
+ case SanitizerHandler::NonnullReturn:
+ return "Returning null pointer from a function which is declared to never "
+ "be null";
+
+ case SanitizerHandler::OutOfBounds:
+ return "Array index out of bounds";
+
+ case SanitizerHandler::PointerOverflow:
+ return "Pointer arithmetic overflowed bounds";
+
+ case SanitizerHandler::ShiftOutOfBounds:
+ return "Shift amount exceeds bit-width of operand";
+
+ case SanitizerHandler::SubOverflow:
+ return "Signed integer subtraction overflowed";
+
+ case SanitizerHandler::TypeMismatch:
+ return "Type mismatch in operation";
+
+ case SanitizerHandler::AlignmentAssumption: // Help on bottom 2
+ return "Alignment assumption violated";
+
+ case SanitizerHandler::VLABoundNotPositive:
+ return "Variable-length array bound is not positive";
----------------
delcypher wrote:
Can we explicitly add
```
case SanitizerHandler::BoundsSafety:
// -fbounds-safety traps are not UBSan traps
return {};
```
So that no one is later tempted to try and add a case at a later date (they might think it's omission is a mistake).
?
https://github.com/llvm/llvm-project/pull/143758
More information about the cfe-commits
mailing list