[PATCH] D60112: [analyzer] Treat write into a top-level parameter variable with destructor as escape.
Kristóf Umann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 10 14:47:54 PDT 2019
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.
Okay, I played around with this patch, I see now where this is going! LGTM!
> Do you think i should document it somehow?
Aye, the description you gave was enlightening, thanks! If you can squeeze it somewhere in the code where it isn't out of place, it's all the better! :)
================
Comment at: clang/test/Analysis/malloc.cpp:151
+ char *getName() {
+ if (!name) {
+ name = static_cast<char *>(malloc(10));
----------------
NoQ wrote:
> Szelethus wrote:
> > Is this relevant? `name` will never be null.
> Not really, just makes the code look a bit more sensible and idiomatic and less warning-worthy-anyway, to make it as clear as possible that the positive here is indeed false. We don't really have a constructor in this class, but we can imagine that it zero-initializes name. Without this check calling `getName()` multiple times would immediately result in a leak.
Convinced ;)
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60112/new/
https://reviews.llvm.org/D60112
More information about the cfe-commits
mailing list