[clang] [ubsan] Add more -fsanitize-annotate-debug-info checks (PR #141997)

Florian Mayer via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 4 12:27:41 PDT 2025


================
@@ -6435,10 +6433,44 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
 #undef SANITIZER_CHECK
   };
 
+  // Label doesn't require sanitization
+
+  return Label;
+}
+
+static std::string
+SanitizerOrdinalToCheckLabel(SanitizerKind::SanitizerOrdinal Ordinal) {
+  std::string Label;
+  switch (Ordinal) {
+#define SANITIZER(NAME, ID)                                                    \
+  case SanitizerKind::SO_##ID:                                                 \
+    Label = "__ubsan_check_" NAME;                                             \
+    break;
+#include "clang/Basic/Sanitizers.def"
+  default:
+    llvm_unreachable("unexpected sanitizer kind");
+  }
+
+  // Sanitize label (convert hyphens to underscores; also futureproof against
+  // non-alpha)
+  for (unsigned int i = 0; i < Label.length(); i++)
+    if (!std::isalpha(Label[i]))
----------------
fmayer wrote:

FYI `isalpha` uses the locale.

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


More information about the cfe-commits mailing list