[PATCH] D98688: [-Wcalled-once-parameter] Harden analysis in terms of block use

Valeriy Savchenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 16 02:16:32 PDT 2021


vsavchenko created this revision.
vsavchenko added a reviewer: NoQ.
Herald added a subscriber: Charusso.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch introduces a very simple inter-procedural analysis
between blocks and enclosing functions.

We always analyze blocks first (analysis is done as part of semantic
analysis that goes side-by-side with the parsing process), and at the
moment of reporting we don't know how that block will be actually
used.

This patch introduces new logic delaying reports of the "never called"
warnings on blocks.  If we are not sure that the block will be called
exactly once, we shouldn't warn our users about that.  Double calls,
however, don't require such delays.  While analyzing the enclosing
function, we can actually decide what we should do with those
warnings.

Additionally, as a side effect, we can be more confident about blocks
in such context and can treat them not as escapes, but as direct
calls.

rdar://74090107


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98688

Files:
  clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaObjC/warn-called-once.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98688.330904.patch
Type: text/x-patch
Size: 23554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210316/efc022e8/attachment-0001.bin>


More information about the cfe-commits mailing list