@@ -1226,16 +1226,8 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound,
12261226
12271227 SanitizerScope SanScope (this );
12281228
1229- llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation ();
12301229 auto CheckKind = SanitizerKind::SO_ArrayBounds;
1231- // TODO: deprecate ClArrayBoundsPseudoFn
1232- if ((ClArrayBoundsPseudoFn ||
1233- CGM.getCodeGenOpts ().SanitizeAnnotateDebugInfo .has (CheckKind)) &&
1234- CheckDI) {
1235- CheckDI = getDebugInfo ()->CreateSyntheticInlineAt (
1236- Builder.getCurrentDebugLocation (), " __ubsan_check_array_bounds" );
1237- }
1238- ApplyDebugLocation ApplyTrapDI (*this , CheckDI);
1230+ ApplyDebugLocation ApplyTrapDI (*this , SanitizerAnnotateDebugInfo (CheckKind));
12391231
12401232 bool IndexSigned = IndexType->isSignedIntegerOrEnumerationType ();
12411233 llvm::Value *IndexVal = Builder.CreateIntCast (Index, SizeTy, IndexSigned);
@@ -1252,6 +1244,35 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound,
12521244 StaticData, Index);
12531245}
12541246
1247+ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo (
1248+ SanitizerKind::SanitizerOrdinal CheckKindOrdinal) {
1249+ std::string Label;
1250+ switch (CheckKindOrdinal) {
1251+ #define SANITIZER (NAME, ID ) \
1252+ case SanitizerKind::SO_##ID: \
1253+ Label = " __ubsan_check_" NAME; \
1254+ break ;
1255+ #include " clang/Basic/Sanitizers.def"
1256+ default :
1257+ llvm_unreachable (" unexpected sanitizer kind" );
1258+ }
1259+
1260+ // Sanitize label
1261+ for (unsigned int i = 0 ; i < Label.length (); i++)
1262+ if (!std::isalpha (Label[i]))
1263+ Label[i] = ' _' ;
1264+
1265+ llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation ();
1266+ // TODO: deprecate ClArrayBoundsPseudoFn
1267+ if (((ClArrayBoundsPseudoFn &&
1268+ CheckKindOrdinal == SanitizerKind::SO_ArrayBounds) ||
1269+ CGM.getCodeGenOpts ().SanitizeAnnotateDebugInfo .has (CheckKindOrdinal)) &&
1270+ CheckDI)
1271+ CheckDI = getDebugInfo ()->CreateSyntheticInlineAt (CheckDI, Label);
1272+
1273+ return CheckDI;
1274+ }
1275+
12551276CodeGenFunction::ComplexPairTy CodeGenFunction::
12561277EmitComplexPrePostIncDec (const UnaryOperator *E, LValue LV,
12571278 bool isInc, bool isPre) {
0 commit comments