[clang] [compiler-rt] [UBSan] Diagnose assumption violation (PR #104741)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 19:47:57 PDT 2024


================
@@ -633,9 +633,11 @@ static void handleInvalidBuiltin(InvalidBuiltinData *Data, ReportOptions Opts) {
 
   ScopedReport R(Opts, Loc, ET);
 
-  Diag(Loc, DL_Error, ET,
-       "passing zero to %0, which is not a valid argument")
-    << ((Data->Kind == BCK_CTZPassedZero) ? "ctz()" : "clz()");
+  if (Data->Kind == BCK_AssumePassedFalse)
+    Diag(Loc, DL_Error, ET, "assumption is violated during execution");
+  else
+    Diag(Loc, DL_Error, ET, "passing zero to %0, which is not a valid argument")
+        << ((Data->Kind == BCK_CTZPassedZero) ? "ctz()" : "clz()");
----------------
vitalybuka wrote:

I suggest introduce `__ubsan::__ubsan_handle_invalid_assume` and we don't need enum here and in Clang.

Also  `__ubsan::__ubsan_handle_invalid_abort` is likely prints garbage.

Would you like to upload a separate patch to fix abort?

https://github.com/llvm/llvm-project/pull/104741


More information about the llvm-commits mailing list