@@ -65,13 +65,6 @@ llvm::cl::opt<bool> ClSanitizeGuardChecks(
6565
6666} // namespace clang
6767
68- // TODO: consider deprecating ClArrayBoundsPseudoFn; functionality is subsumed
69- // by -fsanitize-annotate-debug-info
70- static llvm::cl::opt<bool > ClArrayBoundsPseudoFn (
71- " array-bounds-pseudofn" , llvm::cl::Hidden, llvm::cl::Optional,
72- llvm::cl::desc (" Emit debug info that places array-bounds instrumentation "
73- " in an inline function called __ubsan_check_array_bounds." ));
74-
7568// ===--------------------------------------------------------------------===//
7669// Defines for metadata
7770// ===--------------------------------------------------------------------===//
@@ -755,10 +748,11 @@ void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc,
755748 // SO_Vptr's corresponding handler is DynamicTypeCacheMiss, not TypeMismatch.
756749 // However, it relies upon IsGuaranteedNonNull, hence the instructions cannot
757750 // be fully separated from the TypeMismatch.
758- SanitizerScope SanScope (this ,
759- {SanitizerKind::SO_Null, SanitizerKind::SO_ObjectSize,
760- SanitizerKind::SO_Alignment, SanitizerKind::SO_Vptr},
761- CheckHandler);
751+ SanitizerDebugLocation SanScope (
752+ this ,
753+ {SanitizerKind::SO_Null, SanitizerKind::SO_ObjectSize,
754+ SanitizerKind::SO_Alignment, SanitizerKind::SO_Vptr},
755+ CheckHandler);
762756
763757 SmallVector<std::pair<llvm::Value *, SanitizerKind::SanitizerOrdinal>, 3 >
764758 Checks;
@@ -1235,7 +1229,7 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound,
12351229
12361230 auto CheckKind = SanitizerKind::SO_ArrayBounds;
12371231 auto CheckHandler = SanitizerHandler::OutOfBounds;
1238- SanitizerScope SanScope (this , {CheckKind}, CheckHandler);
1232+ SanitizerDebugLocation SanScope (this , {CheckKind}, CheckHandler);
12391233
12401234 bool IndexSigned = IndexType->isSignedIntegerOrEnumerationType ();
12411235 llvm::Value *IndexVal = Builder.CreateIntCast (Index, SizeTy, IndexSigned);
@@ -1251,37 +1245,6 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound,
12511245 EmitCheck (std::make_pair (Check, CheckKind), CheckHandler, StaticData, Index);
12521246}
12531247
1254- llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo (
1255- ArrayRef<SanitizerKind::SanitizerOrdinal> Ordinals,
1256- SanitizerHandler Handler) {
1257- std::string Label;
1258- switch (Handler) {
1259- #define SANITIZER_CHECK (Enum, Name, Version ) \
1260- case Enum: \
1261- Label = " __ubsan_check_" #Name; \
1262- break ;
1263-
1264- LIST_SANITIZER_CHECKS
1265- #undef SANITIZER_CHECK
1266- };
1267-
1268- llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation ();
1269-
1270- // TODO: the annotation could be more precise e.g.,
1271- // use the ordinal name if there is only one ordinal
1272- for (auto Ord : Ordinals) {
1273- // TODO: deprecate ClArrayBoundsPseudoFn
1274- if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
1275- CGM.getCodeGenOpts ().SanitizeAnnotateDebugInfo .has (Ord)) &&
1276- CheckDI) {
1277- CheckDI = getDebugInfo ()->CreateSyntheticInlineAt (CheckDI, Label);
1278- break ;
1279- }
1280- }
1281-
1282- return CheckDI;
1283- }
1284-
12851248CodeGenFunction::ComplexPairTy CodeGenFunction::
12861249EmitComplexPrePostIncDec (const UnaryOperator *E, LValue LV,
12871250 bool isInc, bool isPre) {
@@ -2008,7 +1971,7 @@ bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType Ty,
20081971
20091972 auto &Ctx = getLLVMContext ();
20101973 auto CheckHandler = SanitizerHandler::LoadInvalidValue;
2011- SanitizerScope SanScope (this , {Kind}, CheckHandler);
1974+ SanitizerDebugLocation SanScope (this , {Kind}, CheckHandler);
20121975 llvm::Value *Check;
20131976 --End;
20141977 if (!Min) {
@@ -3946,7 +3909,7 @@ void CodeGenFunction::EmitCfiCheckFail() {
39463909 // not even be available, if Data == nullptr). However, we still want to
39473910 // annotate the instrumentation. We approximate this by using all the CFI
39483911 // kinds.
3949- SanitizerScope SanScope (
3912+ SanitizerDebugLocation SanScope (
39503913 this ,
39513914 {SanitizerKind::SO_CFIVCall, SanitizerKind::SO_CFINVCall,
39523915 SanitizerKind::SO_CFIDerivedCast, SanitizerKind::SO_CFIUnrelatedCast,
@@ -4051,7 +4014,7 @@ void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {
40514014 if (SanOpts.has (SanitizerKind::Unreachable)) {
40524015 auto CheckOrdinal = SanitizerKind::SO_Unreachable;
40534016 auto CheckHandler = SanitizerHandler::BuiltinUnreachable;
4054- SanitizerScope SanScope (this , {CheckOrdinal}, CheckHandler);
4017+ SanitizerDebugLocation SanScope (this , {CheckOrdinal}, CheckHandler);
40554018 EmitCheck (std::make_pair (static_cast <llvm::Value *>(Builder.getFalse ()),
40564019 CheckOrdinal),
40574020 CheckHandler, EmitCheckSourceLocation (Loc), {});
@@ -6293,7 +6256,7 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
62936256 CGM.getTargetCodeGenInfo ().getUBSanFunctionSignature (CGM)) {
62946257 auto CheckOrdinal = SanitizerKind::SO_Function;
62956258 auto CheckHandler = SanitizerHandler::FunctionTypeMismatch;
6296- SanitizerScope SanScope (this , {CheckOrdinal}, CheckHandler);
6259+ SanitizerDebugLocation SanScope (this , {CheckOrdinal}, CheckHandler);
62976260 auto *TypeHash = getUBSanFunctionTypeHash (PointeeType);
62986261
62996262 llvm::Type *PrefixSigType = PrefixSig->getType ();
@@ -6373,7 +6336,7 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
63736336 (!TargetDecl || !isa<FunctionDecl>(TargetDecl))) {
63746337 auto CheckOrdinal = SanitizerKind::SO_CFIICall;
63756338 auto CheckHandler = SanitizerHandler::CFICheckFail;
6376- SanitizerScope SanScope (this , {CheckOrdinal}, CheckHandler);
6339+ SanitizerDebugLocation SanScope (this , {CheckOrdinal}, CheckHandler);
63776340 EmitSanitizerStatReport (llvm::SanStat_CFI_ICall);
63786341
63796342 llvm::Metadata *MD;
0 commit comments