[PATCH] D105821: [analyzer] [WIP] Model destructor for std::unique_ptr

Deep Majumder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 8 09:39:02 PDT 2021


RedDocMD added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:440
+          State, {std::make_pair(CC->getCXXThisVal(), ArgVal)},
+          C.getLocationContext(), PSK_DirectEscapeOnCall, &Call);
 
----------------
It seems to me that this pointer escape doesn't work.
For the following code:
```lang=cpp
void foo() {
    auto ptr = std::unique_ptr<int>(new int(13));
    // Leak warning emitted here
}
```
the exploded graph shows the SVal for `new int(13)` as allocated instead of escaped (which eventually triggers the warning).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105821



More information about the cfe-commits mailing list