[PATCH] D42192: [analyzer] Assume that the allocated value is non-null before construction, not after.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 11:21:36 PST 2018


NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

In the `c++-allocator-inlining=true` mode, we need to make the assumption that the conservatively evaluated operator new() has returned a non-null value. Previously we did this on `CXXNewExpr`, but now we have to do that before calling the constructor, because some clever constructors are sometimes assuming that their `this` is null and doing weird stuff. We would also crash upon evaluating `CXXNewExpr` when the allocator was inlined and returned null and had a throw specification; this is UB even for custom allocators, but we still need not to crash.

Added more FIXME tests to ensure that eventually we fix calling the constructor for null return values.


Repository:
  rC Clang

https://reviews.llvm.org/D42192

Files:
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/new-ctor-conservative.cpp
  test/Analysis/new-ctor-null-throw.cpp
  test/Analysis/new-ctor-null.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42192.130224.patch
Type: text/x-patch
Size: 6133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180117/9658a667/attachment.bin>


More information about the cfe-commits mailing list