[PATCH] D47554: [analyzer] Check for dead/impossible status checks

Tom Rix via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 30 13:16:55 PDT 2018


trixirt created this revision.
trixirt added a reviewer: dcoughlin.
Herald added subscribers: cfe-commits, a.sidorin, szepet, xazax.hun, mgorny.
Herald added a reviewer: george.karpenkov.

The c++ 'new' function has several variants.
Only the no-throw versions of these return a nullptr on failure.
Error handling based on tha nullptr check for the throw version
is dead code.

ex/

char *n = new char[x];
if (n == nullptr)  // this is dead/impossible code

  do_something();


Repository:
  rC Clang

https://reviews.llvm.org/D47554

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/DeadStatusChecker.cpp
  test/Analysis/dead-status-new-nullptr.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47554.149190.patch
Type: text/x-patch
Size: 6409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180530/5f6779e5/attachment.bin>


More information about the cfe-commits mailing list