[PATCH] D66733: [analyzer] Add a checker option to detect nested dead stores

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 26 04:50:21 PDT 2019


steakhal created this revision.
steakhal added reviewers: NoQ, krememek, Szelethus, baloghadamsoftware.
Herald added subscribers: cfe-commits, Charusso, donat.nagy, dexonsmith, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
Herald added a project: clang.

Enables the users to specify an optional flag which would warn for more dead stores.
Previously it ignored if the dead store happened e.g. in an if condition.

  if ((X = generate())) { // dead store to X
  }

This patch introduces the `WarnForDeadNestedAssignments` option to the checker, which is `false` by default - so this change would not affect any previous users.
I have updated the code, tests and the docs as well. If I missed something, tell me.

I also ran the analysis on Clang which generated 14 more reports compared to the unmodified version. All of them seemed reasonable for me.
Shouldn't we enable this option by default?
You can check those at this CodeChecker instance <http://cc.elte.hu:15200/Default/#run=before%20deadstore%20option&newcheck=after%20deadstore%20option&review-status=Unreviewed&review-status=Confirmed&detection-status=New&detection-status=Reopened&detection-status=Unresolved&tab=before%20deadstore%20option_diff_after%20deadstore%20option>. Note that this link will no longer work after the patch has been accepted.

Related previous patches:
rGf224820b45c6847b91071da8d7ade59f373b96f3 <https://reviews.llvm.org/rGf224820b45c6847b91071da8d7ade59f373b96f3>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66733

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/dead-stores.c
  clang/test/Analysis/dead-stores.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66733.217089.patch
Type: text/x-patch
Size: 10264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190826/990af841/attachment.bin>


More information about the cfe-commits mailing list