[clang][dataflow] Handle multiple context-sensitive calls to the same function
authorSam Estep <sam@samestep.com>
Fri, 29 Jul 2022 19:39:52 +0000 (19:39 +0000)
committerSam Estep <sam@samestep.com>
Fri, 29 Jul 2022 19:40:19 +0000 (19:40 +0000)
commita6ddc68487823d48c0ec0ddd649ace4a2732d0b0
treeb75167f909f55c86d249b7d66e08c2a1cd5a170f
parent09c41211231578765cdb296bda3b4c7f3c22b4ba
[clang][dataflow] Handle multiple context-sensitive calls to the same function

This patch enables context-sensitive analysis of multiple different calls to the same function (see the `ContextSensitiveSetBothTrueAndFalse` example in the `TransferTest` suite) by replacing the `Environment` copy-assignment with a call to the new `popCall` method, which  `std::move`s some fields but specifically does not move `DeclToLoc` and `ExprToLoc` from the callee back to the caller.

To enable this, the `StorageLocation` for a given parameter needs to be stable across different calls to the same function, so this patch also improves the modeling of parameter initialization, using `ReferenceValue` when necessary (for arguments passed by reference).

This approach explicitly does not work for recursive calls, because we currently only plan to use this context-sensitive machinery to support specialized analysis models we write, not analysis of arbitrary callees.

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D130726
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/include/clang/Analysis/FlowSensitive/Transfer.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp