[clang] [Sema] Fix lifetime extension for temporaries in range-based for loops in C++23 (PR #145164)

Marco Vitale via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 3 11:43:09 PDT 2025


mrcvtl wrote:

> There are some test failures in the presubmit checks, you probably need to update these tests.

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? 


https://github.com/llvm/llvm-project/pull/145164


More information about the cfe-commits mailing list