[clang] [Sanitize] fix crash in -fsanitize-annotate-debug-info (PR #149237)
Thurston Dang via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 16 20:13:05 PDT 2025
================
@@ -6480,20 +6480,23 @@ SanitizerOrdinalToCheckLabel(SanitizerKind::SanitizerOrdinal Ordinal) {
llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
ArrayRef<SanitizerKind::SanitizerOrdinal> Ordinals,
SanitizerHandler Handler) {
+ llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation();
+ auto *DI = getDebugInfo();
+ if (!DI)
+ return CheckDI;
+
std::string Label;
if (Ordinals.size() == 1)
Label = SanitizerOrdinalToCheckLabel(Ordinals[0]);
else
Label = SanitizerHandlerToCheckLabel(Handler);
- llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation();
-
for (auto Ord : Ordinals) {
// TODO: deprecate ClArrayBoundsPseudoFn
if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(Ord)) &&
CheckDI) {
----------------
thurstond wrote:
Q: does the DI check above provide any guarantees that CheckDI is non-null? (i.e., can `&& CheckDI` be safely elided or does it require further working group approval?)
https://github.com/llvm/llvm-project/pull/149237
More information about the cfe-commits
mailing list