NoQ added a comment.

In D82598#2116373 <https://reviews.llvm.org/D82598#2116373>, @xazax.hun wrote:

> > I suspect that it would be pretty bad if you, say, kill the condition of 
> > the `if`-statement before picking the branch. Or kill the initializer in 
> > the `DeclStmt` before putting it into the variable (same for 
> > `CXXCtorInitializer` which isn't even a `Stmt`!).
>
> I would argue that the end of the full expression is AFTER the `if` was 
> evaluated in this case. But I do see what you mean, thanks :)


Well, formally it isn't. The notion of full-expression is defined pretty 
strictly because that's the moment of time when temporary destructors are 
invoked. So the language pays a lot of attention to what exactly constitutes an 
expression, and as of now if-statements don't. In particular, temporary 
destructors will run before the branch is chosen.

I guess your point is that live expressions analysis could be replaced with 
imperative cleanup requests from, say, `ExprEngine` to the `Environment`. I.e., 
"We've just finished evaluating the if-statement, now we should actively tell 
the Environment to remove the condition expression". I guess it could totally 
work that way, but it'd be pretty hard to not forget such cleanups. Given that 
we'd also barely ever notice that we forgot one of those, i'm very much in 
favor of having liveness analysis instead, that would declaratively describe 
which expressions are live when, so that to automatically guarantee that we 
always only track what's necessary and never snowball our state with dead 
expressions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82598/new/

https://reviews.llvm.org/D82598



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to