[all-commits] [llvm/llvm-project] 4b2fff: [LifetimeSafety] Handle xvalue operand of LValueTo...
Zhijie Wang via All-commits
all-commits at lists.llvm.org
Fri Apr 17 01:39:53 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4b2fffab5620fb937e96ef3f2911fc79a3703081
https://github.com/llvm/llvm-project/commit/4b2fffab5620fb937e96ef3f2911fc79a3703081
Author: Zhijie Wang <yesterda9 at gmail.com>
Date: 2026-04-17 (Fri, 17 Apr 2026)
Changed paths:
M clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp
M clang/test/Sema/warn-lifetime-safety-suggestions.cpp
Log Message:
-----------
[LifetimeSafety] Handle xvalue operand of LValueToRValue cast (#192312)
Under C++23, P2266 wraps the operand of `return p;` in an xvalue NoOp
cast for by-value parameters. The `CK_LValueToRValue` branch in
FactsGenerator guarded on `!SubExpr->isLValue()`, breaking origin flow
and silencing the suggestion for `int* id(int* p) { return p; }`.
Use `isGLValue()`, matching how origins are built and stripped elsewhere
in the analysis.
Only add a RUN in suggestion test file, since some tests in
`warn-lifetime-safety.cpp` cause a hard error under C++23. For example:
`MyObj& f() { MyObj s; return s; }`. `error: non-const lvalue reference
to type 'MyObj' cannot bind to a temporary of type 'MyObj'`.
Fixes: #176292
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list