[clang] 1b8a136 - [Sanitizer] remove array-bounds-pseudofn (#149430)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 18 14:31:24 PDT 2025


Author: Florian Mayer
Date: 2025-07-18T14:31:21-07:00
New Revision: 1b8a136a09bfed49ae008a354946804230055153

URL: https://github.com/llvm/llvm-project/commit/1b8a136a09bfed49ae008a354946804230055153
DIFF: https://github.com/llvm/llvm-project/commit/1b8a136a09bfed49ae008a354946804230055153.diff

LOG: [Sanitizer] remove array-bounds-pseudofn (#149430)

This has been replaced by -fsanitize-annotate-debug-info

Added: 
    

Modified: 
    clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 446cf8d9e05c6..d6a5c4c476d5c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -58,13 +58,6 @@
 using namespace clang;
 using namespace clang::CodeGen;
 
-// TODO: consider deprecating ClArrayBoundsPseudoFn; functionality is subsumed
-//       by -fsanitize-annotate-debug-info
-static llvm::cl::opt<bool> ClArrayBoundsPseudoFn(
-    "array-bounds-pseudofn", llvm::cl::Hidden, llvm::cl::Optional,
-    llvm::cl::desc("Emit debug info that places array-bounds instrumentation "
-                   "in an inline function called __ubsan_check_array_bounds."));
-
 static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext &Ctx) {
   auto TI = Ctx.getTypeInfo(Ty);
   if (TI.isAlignRequired())
@@ -6482,7 +6475,11 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
     SanitizerHandler Handler) {
   llvm::DILocation *CheckDebugLoc = Builder.getCurrentDebugLocation();
   auto *DI = getDebugInfo();
-  if (!DI)
+  if (!DI || !CheckDebugLoc)
+    return CheckDebugLoc;
+  const auto &AnnotateDebugInfo =
+      CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo;
+  if (AnnotateDebugInfo.empty())
     return CheckDebugLoc;
 
   std::string Label;
@@ -6491,14 +6488,8 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
   else
     Label = SanitizerHandlerToCheckLabel(Handler);
 
-  for (auto Ord : Ordinals) {
-    // TODO: deprecate ClArrayBoundsPseudoFn
-    if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
-         CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(Ord)) &&
-        CheckDebugLoc) {
-      return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label);
-    }
-  }
+  if (any_of(Ordinals, [&](auto Ord) { return AnnotateDebugInfo.has(Ord); }))
+    return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label);
 
   return CheckDebugLoc;
 }


        


More information about the cfe-commits mailing list