[PATCH] D75430: [analyzer][NFC] Introduce CXXDeallocatorCall, deploy it in MallocChecker

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 4 03:59:05 PST 2020


steakhal added inline comments.


================
Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:958
+
+  unsigned getNumArgs() const override { return getDecl()->getNumParams(); }
+
----------------
NoQ wrote:
> Charusso wrote:
> > `return getOriginExpr()->getNumArgs()`
> This wouldn't compile. `CXXDeleteExpr` is not a `CallExpr`.
> 
> It sounds like there are currently [[ http://www.cplusplus.com/reference/new/operator%20delete/ | five different `operator delete`s ]]:
> {F11474783}
> 
> And, unlike `operator new`, there's no option to provide custom "placement" arguments.
> 
> So i think the logic in this patch is correct but we should do some custom logic for all 5 cases in the `getArgExpr` method, where argument expressions for the extra arguments will have to be conjured out of thin air (or we might as well return null).
> It sounds like there are currently five different `operator delete`s:
I think it is even worse since C++17 and C++20 introduced a couple of others like:
 - overloads with `std::align_val_t` parameter (C++17)
 - overloads with `std::destroying_delete_t` parameter (C++20) which I haven't heard of yet :D

You can check it in the draft: http://eel.is/c++draft/new.delete
And of course at cppreference as well: https://en.cppreference.com/w/cpp/memory/new/operator_delete


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75430





More information about the cfe-commits mailing list