@@ -1223,6 +1223,27 @@ static bool isObjCPointer(const ValueDecl *D) {
1223
1223
return D->getType ()->isObjCObjectPointerType ();
1224
1224
}
1225
1225
1226
+ namespace {
1227
+ using DestTypeValue = std::pair<const StoreInfo &, loc::ConcreteInt>;
1228
+
1229
+ llvm::raw_ostream &operator <<(llvm::raw_ostream &OS, const DestTypeValue &Val) {
1230
+ if (auto *TyR = Val.first .Dest ->getAs <TypedRegion>()) {
1231
+ QualType LocTy = TyR->getLocationType ();
1232
+ if (!LocTy.isNull ()) {
1233
+ if (auto *PtrTy = LocTy->getAs <PointerType>()) {
1234
+ std::string PStr = PtrTy->getPointeeType ().getAsString ();
1235
+ if (!PStr.empty ())
1236
+ OS << " (" << PStr << " )" ;
1237
+ }
1238
+ }
1239
+ }
1240
+ SmallString<16 > ValStr;
1241
+ Val.second .getValue ()->toString (ValStr, 10 , true );
1242
+ OS << ValStr;
1243
+ return OS;
1244
+ }
1245
+ } // namespace
1246
+
1226
1247
// / Show diagnostics for initializing or declaring a region \p R with a bad value.
1227
1248
static void showBRDiagnostics (llvm::raw_svector_ostream &OS, StoreInfo SI) {
1228
1249
const bool HasPrefix = SI.Dest ->canPrintPretty ();
@@ -1245,8 +1266,11 @@ static void showBRDiagnostics(llvm::raw_svector_ostream &OS, StoreInfo SI) {
1245
1266
llvm_unreachable (" Unexpected store kind" );
1246
1267
}
1247
1268
1248
- if (isa<loc::ConcreteInt>(SI.Value )) {
1249
- OS << Action << (isObjCPointer (SI.Dest ) ? " nil" : " a null pointer value" );
1269
+ if (auto CVal = SI.Value .getAs <loc::ConcreteInt>()) {
1270
+ if (!*CVal->getValue ())
1271
+ OS << Action << (isObjCPointer (SI.Dest ) ? " nil" : " a null pointer value" );
1272
+ else
1273
+ OS << Action << DestTypeValue (SI, *CVal);
1250
1274
1251
1275
} else if (auto CVal = SI.Value .getAs <nonloc::ConcreteInt>()) {
1252
1276
OS << Action << CVal->getValue ();
@@ -1288,8 +1312,12 @@ static void showBRParamDiagnostics(llvm::raw_svector_ostream &OS,
1288
1312
1289
1313
OS << " Passing " ;
1290
1314
1291
- if (isa<loc::ConcreteInt>(SI.Value )) {
1292
- OS << (isObjCPointer (D) ? " nil object reference" : " null pointer value" );
1315
+ if (auto CI = SI.Value .getAs <loc::ConcreteInt>()) {
1316
+ if (!*CI->getValue ())
1317
+ OS << (isObjCPointer (D) ? " nil object reference" : " null pointer value" );
1318
+ else
1319
+ OS << (isObjCPointer (D) ? " object reference of value " : " pointer value " )
1320
+ << DestTypeValue (SI, *CI);
1293
1321
1294
1322
} else if (SI.Value .isUndef ()) {
1295
1323
OS << " uninitialized value" ;
@@ -1324,11 +1352,24 @@ static void showBRDefaultDiagnostics(llvm::raw_svector_ostream &OS,
1324
1352
StoreInfo SI) {
1325
1353
const bool HasSuffix = SI.Dest ->canPrintPretty ();
1326
1354
1327
- if (isa<loc::ConcreteInt>(SI.Value )) {
1328
- OS << (isObjCPointer (SI.Dest ) ? " nil object reference stored"
1329
- : (HasSuffix ? " Null pointer value stored"
1330
- : " Storing null pointer value" ));
1331
-
1355
+ if (auto CV = SI.Value .getAs <loc::ConcreteInt>()) {
1356
+ APSIntPtr V = CV->getValue ();
1357
+ if (!*V)
1358
+ OS << (isObjCPointer (SI.Dest )
1359
+ ? " nil object reference stored"
1360
+ : (HasSuffix ? " Null pointer value stored"
1361
+ : " Storing null pointer value" ));
1362
+ else {
1363
+ if (isObjCPointer (SI.Dest )) {
1364
+ OS << " object reference of value " << DestTypeValue (SI, *CV)
1365
+ << " stored" ;
1366
+ } else {
1367
+ if (HasSuffix)
1368
+ OS << " Pointer value of " << DestTypeValue (SI, *CV) << " stored" ;
1369
+ else
1370
+ OS << " Storing pointer value of " << DestTypeValue (SI, *CV);
1371
+ }
1372
+ }
1332
1373
} else if (SI.Value .isUndef ()) {
1333
1374
OS << (HasSuffix ? " Uninitialized value stored"
1334
1375
: " Storing uninitialized value" );
0 commit comments