[PATCH] D61051: [analyzer] Treat functions without runtime branches as "small".

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 23 18:56:16 PDT 2019


NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet, eraman.
Herald added a project: clang.

Currently we always inline functions that have no branches, i.e. have exactly three CFG blocks: [B2 <https://reviews.llvm.org/B2>] ENTRY, [B1 <https://reviews.llvm.org/B1>] some code, [B0] EXIT. This makes sense because when there are no branches, it means that there's no exponential complexity introduced by inlining such function. Such functions also don't trigger various fundamental problems with our inlining mechanism, such as the problem of inlined defensive checks.

Sometimes the CFG may contain more blocks, but in practice it still has linear structure because all directions (except, at most, one) of all branches turned out to be unreachable. When this happens, still treat the function as "small".

This is useful, in particular, for dealing with C++17 `if constexpr`.


Repository:
  rC Clang

https://reviews.llvm.org/D61051

Files:
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/Analysis/CFG.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/test/Analysis/inline-if-constexpr.cpp
  clang/unittests/Analysis/CFGTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61051.196366.patch
Type: text/x-patch
Size: 11980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190424/348c4067/attachment-0001.bin>


More information about the cfe-commits mailing list