5858using namespace clang ;
5959using namespace clang ::CodeGen;
6060
61- // TODO: consider deprecating ClArrayBoundsPseudoFn; functionality is subsumed
62- // by -fsanitize-annotate-debug-info
63- static llvm::cl::opt<bool > ClArrayBoundsPseudoFn (
64- " array-bounds-pseudofn" , llvm::cl::Hidden, llvm::cl::Optional,
65- llvm::cl::desc (" Emit debug info that places array-bounds instrumentation "
66- " in an inline function called __ubsan_check_array_bounds." ));
67-
6861static uint32_t getTypeAlignIfRequired (const Type *Ty, const ASTContext &Ctx) {
6962 auto TI = Ctx.getTypeInfo (Ty);
7063 if (TI.isAlignRequired ())
@@ -6482,7 +6475,11 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
64826475 SanitizerHandler Handler) {
64836476 llvm::DILocation *CheckDebugLoc = Builder.getCurrentDebugLocation ();
64846477 auto *DI = getDebugInfo ();
6485- if (!DI)
6478+ if (!DI || !CheckDebugLoc)
6479+ return CheckDebugLoc;
6480+ const auto &AnnotateDebugInfo =
6481+ CGM.getCodeGenOpts ().SanitizeAnnotateDebugInfo ;
6482+ if (AnnotateDebugInfo.empty ())
64866483 return CheckDebugLoc;
64876484
64886485 std::string Label;
@@ -6491,14 +6488,8 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
64916488 else
64926489 Label = SanitizerHandlerToCheckLabel (Handler);
64936490
6494- for (auto Ord : Ordinals) {
6495- // TODO: deprecate ClArrayBoundsPseudoFn
6496- if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
6497- CGM.getCodeGenOpts ().SanitizeAnnotateDebugInfo .has (Ord)) &&
6498- CheckDebugLoc) {
6499- return DI->CreateSyntheticInlineAt (CheckDebugLoc, Label);
6500- }
6501- }
6491+ if (any_of (Ordinals, [&](auto Ord) { return AnnotateDebugInfo.has (Ord); }))
6492+ return DI->CreateSyntheticInlineAt (CheckDebugLoc, Label);
65026493
65036494 return CheckDebugLoc;
65046495}
0 commit comments