[clang] [LifetimeSafety] Overhaul CFG and analysis to also work with trivially destructed temporary objects (PR #177985)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 10 10:55:19 PST 2026
================
@@ -298,19 +298,19 @@ std::string_view danglingRefToOptionalFromTemp4() {
void danglingReferenceFromTempOwner() {
int &&r = *std::optional<int>(); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} \
// cfg-warning {{object whose reference is captured does not live long enough}} cfg-note {{destroyed here}}
- // FIXME: Detect this using the CFG-based lifetime analysis.
// https://github.com/llvm/llvm-project/issues/175893
- int &&r2 = *std::optional<int>(5); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+ int &&r2 = *std::optional<int>(5); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} \
+ // cfg-warning {{object whose reference is captured does not live long enough}} cfg-note {{destroyed here}}
- // FIXME: Detect this using the CFG-based lifetime analysis.
// https://github.com/llvm/llvm-project/issues/175893
- int &&r3 = std::optional<int>(5).value(); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+ int &&r3 = std::optional<int>(5).value(); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} \
----------------
usx95 wrote:
Could you please add a fixes link to the end of the description for all the bugs that this will fix. Example
Fixes https://github.com/llvm/llvm-project/issues/175893
https://github.com/llvm/llvm-project/pull/177985
More information about the cfe-commits
mailing list