@@ -1223,6 +1223,27 @@ static bool isObjCPointer(const ValueDecl *D) {
12231223 return D->getType ()->isObjCObjectPointerType ();
12241224}
12251225
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+
12261247// / Show diagnostics for initializing or declaring a region \p R with a bad value.
12271248static void showBRDiagnostics (llvm::raw_svector_ostream &OS, StoreInfo SI) {
12281249 const bool HasPrefix = SI.Dest ->canPrintPretty ();
@@ -1245,8 +1266,11 @@ static void showBRDiagnostics(llvm::raw_svector_ostream &OS, StoreInfo SI) {
12451266 llvm_unreachable (" Unexpected store kind" );
12461267 }
12471268
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);
12501274
12511275 } else if (auto CVal = SI.Value .getAs <nonloc::ConcreteInt>()) {
12521276 OS << Action << CVal->getValue ();
@@ -1288,8 +1312,12 @@ static void showBRParamDiagnostics(llvm::raw_svector_ostream &OS,
12881312
12891313 OS << " Passing " ;
12901314
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);
12931321
12941322 } else if (SI.Value .isUndef ()) {
12951323 OS << " uninitialized value" ;
@@ -1324,11 +1352,24 @@ static void showBRDefaultDiagnostics(llvm::raw_svector_ostream &OS,
13241352 StoreInfo SI) {
13251353 const bool HasSuffix = SI.Dest ->canPrintPretty ();
13261354
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+ }
13321373 } else if (SI.Value .isUndef ()) {
13331374 OS << (HasSuffix ? " Uninitialized value stored"
13341375 : " Storing uninitialized value" );
0 commit comments