[clang] [clang][dataflow] Process terminator condition within `transferCFGBlock()`. (PR #77750)
Yitzhak Mandelbaum via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 11 08:15:24 PST 2024
================
@@ -489,6 +482,31 @@ transferCFGBlock(const CFGBlock &Block, AnalysisContext &AC,
}
AC.Log.recordState(State);
}
+
+ // If we have a terminator, evaluate its condition.
+ // This `Expr` may not appear as a `CFGElement` anywhere else, and it's
+ // important that we evaluate it here (rather than while processing the
+ // terminator) so that we put the corresponding value in the right
+ // environment.
+ if (const Expr *TerminatorCond =
+ dyn_cast_or_null<Expr>(Block.getTerminatorCondition())) {
+ if (State.Env.getValue(*TerminatorCond) == nullptr)
+ // FIXME: This only runs the builtin transfer, not the analysis-specific
+ // transfer. Fixing this isn't trivial, as the analysis-specific transfer
+ // takes a `CFGElement` as input, but some expressions only show up as a
+ // terminator condition, but not as a `CFGElement`. The condition of an if
----------------
ymand wrote:
CFGElement is cheap to construct. Can you just wrap the expression and pass it on?
https://github.com/llvm/llvm-project/pull/77750
More information about the cfe-commits
mailing list