[clang] [ubsan] Add more -fsanitize-annotate-debug-info checks (PR #141997)
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Thu May 29 12:53:05 PDT 2025
================
@@ -1245,30 +1245,23 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound,
}
llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
- SanitizerKind::SanitizerOrdinal CheckKindOrdinal) {
- std::string Label;
- switch (CheckKindOrdinal) {
-#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
- for (unsigned int i = 0; i < Label.length(); i++)
- if (!std::isalpha(Label[i]))
- Label[i] = '_';
-
+ ArrayRef<SanitizerKind::SanitizerOrdinal> Ordinals) {
llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation();
- // TODO: deprecate ClArrayBoundsPseudoFn
- if (((ClArrayBoundsPseudoFn &&
- CheckKindOrdinal == SanitizerKind::SO_ArrayBounds) ||
- CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(CheckKindOrdinal)) &&
- CheckDI)
- CheckDI = getDebugInfo()->CreateSyntheticInlineAt(CheckDI, Label);
+
+ // TODO: the annotation could be more precise:
+ // 1) use the ordinal name if there is only one ordinal; and/or,
+ // 2) use the overarching SanitizerHandler if there are multiple ordinals
+ // (this may be confusing to users)
+ for (auto Ord : Ordinals) {
+ // TODO: deprecate ClArrayBoundsPseudoFn
+ if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
+ CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(Ord)) &&
+ CheckDI) {
+ CheckDI = getDebugInfo()->CreateSyntheticInlineAt(
+ CheckDI, "__ubsan_check_singularity");
----------------
vitalybuka wrote:
Not sure I understand the name.
__ubsan_check_singularity -> __ubsan_check_debug_info_{anchor,holder}?
https://github.com/llvm/llvm-project/pull/141997
More information about the cfe-commits
mailing list