@@ -1226,16 +1226,8 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound,
1226
1226
1227
1227
SanitizerScope SanScope (this );
1228
1228
1229
- llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation ();
1230
1229
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));
1239
1231
1240
1232
bool IndexSigned = IndexType->isSignedIntegerOrEnumerationType ();
1241
1233
llvm::Value *IndexVal = Builder.CreateIntCast (Index, SizeTy, IndexSigned);
@@ -1252,6 +1244,35 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound,
1252
1244
StaticData, Index);
1253
1245
}
1254
1246
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
+
1255
1276
CodeGenFunction::ComplexPairTy CodeGenFunction::
1256
1277
EmitComplexPrePostIncDec (const UnaryOperator *E, LValue LV,
1257
1278
bool isInc, bool isPre) {
0 commit comments