[clang] [clang][nullability] Don't discard expression state before end of full-expression. (PR #82611)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 7 04:10:14 PST 2024
================
@@ -307,7 +310,22 @@ computeBlockInputState(const CFGBlock &Block, AnalysisContext &AC) {
}
}
- JoinedStateBuilder Builder(AC);
+ // If any of the predecessor blocks contains an expression consumed in a
+ // different block, we need to keep expression state.
+ // Note that in this case, we keep expression state for all predecessors,
+ // rather than only those predecessors that actually contain an expression
+ // consumed in a different block. While this is potentially suboptimal, it's
+ // actually likely, if we have control flow within a full expression, that
+ // all predecessors have expression state consumed in a different block.
+ Environment::ExprJoinBehavior ExprBehavior = Environment::DiscardExprState;
+ for (const CFGBlock *Pred : Preds) {
+ if (Pred && AC.CFCtx.containsExprConsumedInDifferentBlock(*Pred)) {
+ ExprBehavior = Environment::KeepExprState;
+ break;
+ }
+ }
----------------
martinboehme wrote:
I'm still not sure this is worth it - this would add additional stored state (even if it's non-mutable), and I'm not sure this is worth it for the small gain we get. Will commit as-is, and we can discuss whether we want to create a followup patch for this.
https://github.com/llvm/llvm-project/pull/82611
More information about the cfe-commits
mailing list