]> granicus.if.org Git - clang/commit
[analyzer] Treat functions without run-time branches as "small".
authorArtem Dergachev <artem.dergachev@gmail.com>
Tue, 30 Apr 2019 03:01:02 +0000 (03:01 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Tue, 30 Apr 2019 03:01:02 +0000 (03:01 +0000)
commitc208eda5d902a10fcbc85024a06a60f72fbed767
treeb07ebad2889f75d147d3c47c6b888e71e61a8023
parent4ecb1e1c614b63724545e32904ca321e148e629c
[analyzer] Treat functions without run-time branches as "small".

Currently we always inline functions that have no branches, i.e. have exactly
three CFG blocks: ENTRY, some code, 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.

Differential Revision: https://reviews.llvm.org/D61051

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359531 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Analysis/CFG.h
include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
lib/Analysis/CFG.cpp
lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
test/Analysis/inline-if-constexpr.cpp [new file with mode: 0644]
unittests/Analysis/CFGTest.cpp