[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

Deep Majumder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 11 09:25:05 PST 2021


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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97183.329989.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210311/83c7b29b/attachment.bin>


More information about the cfe-commits mailing list