[clang] [Sema] Fix lifetime extension for temporaries in range-based for loops in C++23 (PR #145164)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 4 01:08:38 PDT 2025
hokein wrote:
> Yes, indeed. For example, in `AST/ast-dump-for-range-lifetime.cpp` we move from: `-MaterializeTemporaryExpr {{.*}} 'C':'P2718R0::C' xvalue extended by Var {{.*}} '__range1' 'C &&'` to: `-MaterializeTemporaryExpr {{.*}} 'C':'P2718R0::C' xvalue`. At a first look it seems like we are losing info in the AST, but also a couple of line later we got: `-MaterializeTemporaryExpr {{.*}} 'const C':'const P2718R0::C' lvalue extended by Var {{.*}} '__range1' 'C &&'` So it might be fine...
>
> In `special/class.temporary/p6.cpp` instead is a bit more weird, because it seems we are losing some IR call in case of for-range loops. You can take a look in the logs of the failing test.
>
> Given that I don't know enough about it to say if it is okay or not, I wanted to double check with you. What do you think?
Thanks for looking at them.
It seems this patch is causing some unexpected behavior changes. From what I can tell, this patch only adds a new bit to Decl, which shouldn’t affect the two failing tests. However, I don't spot any obvious cause by reading the patch. Maybe @yronglin has some insights here.
https://github.com/llvm/llvm-project/pull/145164
More information about the cfe-commits
mailing list