[PATCH] D98726: [analyzer] Remove unnecessary TODO

Deep Majumder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 16 22:43:06 PDT 2021


RedDocMD updated this revision to Diff 331164.
RedDocMD added a comment.

Removed unnecessary include


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98726/new/

https://reviews.llvm.org/D98726

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp


Index: clang/test/Analysis/smart-ptr-text-output.cpp
===================================================================
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1\
-// RUN:  -analyzer-checker=core,cplusplus.Move,alpha.cplusplus.SmartPtr\
+// RUN:  -analyzer-checker=core,cplusplus.Move,cplusplus.NewDelete,alpha.cplusplus.SmartPtr\
 // RUN:  -analyzer-config cplusplus.SmartPtrModeling:ModelSmartPtrDereference=true\
 // RUN:  -analyzer-output=text -std=c++11 %s -verify=expected
 
@@ -43,6 +43,14 @@
   // expected-note at -1{{Dereference of null smart pointer 'P'}}
 }
 
+void derefOfReleasedPtr(A *oldptr) {
+  std::unique_ptr<A> P(oldptr);
+  A* aptr = P.release();
+  delete aptr; // expected-note {{Memory is released}}
+  aptr->foo(); // expected-warning {{Use of memory after it is freed [cplusplus.NewDelete]}}
+  // expected-note at -1{{Use of memory after it is freed}}
+}
+
 void derefAfterReset() {
   std::unique_ptr<A> P(new A()); // expected-note {{Smart pointer 'P' is constructed}}
   P.reset(); // expected-note {{Smart pointer 'P' reset using a null value}}
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -391,8 +391,6 @@
     checkAndPrettyPrintRegion(OS, ThisRegion);
     OS << " is released and set to null";
   }));
-  // TODO: Add support to enable MallocChecker to start tracking the raw
-  // pointer.
 }
 
 void SmartPtrModeling::handleSwap(const CallEvent &Call,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98726.331164.patch
Type: text/x-patch
Size: 1693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210317/05119bbe/attachment.bin>


More information about the cfe-commits mailing list