[clang][dataflow] Fix crash when RHS of `&&` or `||` calls `noreturn` func.
authorMartin Braenne <mboehme@google.com>
Thu, 23 Mar 2023 07:45:40 +0000 (07:45 +0000)
committerMartin Braenne <mboehme@google.com>
Thu, 23 Mar 2023 08:02:43 +0000 (08:02 +0000)
commit5acd29eb4d9e411b3631c26babcd1d2655623f4a
tree2c5cc47224367e4b5c2bb2364b5ef00e0f9576f9
parent467cf1542808851773500fe0af0da916f46fa80c
[clang][dataflow] Fix crash when RHS of `&&` or `||` calls `noreturn` func.

The crash happened because the transfer fucntion for `&&` and `||`
unconditionally tried to retrieve the value of the RHS. However, if the RHS
is unreachable, there is no environment for it, and trying to retrieve the
operand's value causes an assertion failure.

See also the comments in the code for further details.

Reviewed By: xazax.hun, ymandel, sgatev, gribozavr2

Differential Revision: https://reviews.llvm.org/D146514
clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
clang/include/clang/Analysis/FlowSensitive/Transfer.h
clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp