RedDocMD updated this revision to Diff 329989. RedDocMD added a comment. Calling trackExpressionValue to mark InnerPointerVal as interesting
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97183/new/ https://reviews.llvm.org/D97183 Files: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp @@ -464,7 +464,7 @@ if (&BR.getBugType() != smartptr::getNullDereferenceBugType() || !BR.isInteresting(ThisRegion)) return; - if (!State->assume(InnerPointerVal.castAs<DefinedSVal>(), true)) + if (!BR.isInteresting(InnerPointerVal) || !BR.isInteresting(InnerPointerVal.getAsSymbol())) return; if (ThisRegion->canPrintPretty()) { OS << "Obtained null inner pointer from"; Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp @@ -87,7 +87,12 @@ auto R = std::make_unique<PathSensitiveBugReport>(NullDereferenceBugType, OS.str(), ErrNode); R->markInteresting(DerefRegion); - C.emitReport(std::move(R)); + const Expr *BugExpr = Call.getOriginExpr(); + const ProgramStateRef State = C.getState(); + if (const ExplodedNode *E = C.generateNonFatalErrorNode(State)) { + bugreporter::trackExpressionValue(E, BugExpr, *R); + C.emitReport(std::move(R)); + } } void SmartPtrChecker::explainDereference(llvm::raw_ostream &OS,
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp @@ -464,7 +464,7 @@ if (&BR.getBugType() != smartptr::getNullDereferenceBugType() || !BR.isInteresting(ThisRegion)) return; - if (!State->assume(InnerPointerVal.castAs<DefinedSVal>(), true)) + if (!BR.isInteresting(InnerPointerVal) || !BR.isInteresting(InnerPointerVal.getAsSymbol())) return; if (ThisRegion->canPrintPretty()) { OS << "Obtained null inner pointer from"; Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp @@ -87,7 +87,12 @@ auto R = std::make_unique<PathSensitiveBugReport>(NullDereferenceBugType, OS.str(), ErrNode); R->markInteresting(DerefRegion); - C.emitReport(std::move(R)); + const Expr *BugExpr = Call.getOriginExpr(); + const ProgramStateRef State = C.getState(); + if (const ExplodedNode *E = C.generateNonFatalErrorNode(State)) { + bugreporter::trackExpressionValue(E, BugExpr, *R); + C.emitReport(std::move(R)); + } } void SmartPtrChecker::explainDereference(llvm::raw_ostream &OS,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits