diff --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/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,
diff --git a/clang/test/Analysis/smart-ptr-text-output.cpp b/clang/test/Analysis/smart-ptr-text-output.cpp
--- a/clang/test/Analysis/smart-ptr-text-output.cpp
+++ b/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@-1{{Dereference of null smart pointer 'P'}}
}
+void derefOfReleasedPtr(A *oldptr) {
+ std::unique_ptr 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@-1{{Use of memory after it is freed}}
+}
+
void derefAfterReset() {
std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is constructed}}
P.reset(); // expected-note {{Smart pointer 'P' reset using a null value}}