[all-commits] [llvm/llvm-project] 465673: [CFG] Fix cleanup ordering for CXXDefaultInitExpr

Utkarsh Saxena via All-commits all-commits at lists.llvm.org
Mon Apr 13 10:13:13 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 465673edc3abdb7f0fc595dc790ad421cc022513
      https://github.com/llvm/llvm-project/commit/465673edc3abdb7f0fc595dc790ad421cc022513
  Author: Utkarsh Saxena <usx at google.com>
  Date:   2026-04-13 (Mon, 13 Apr 2026)

  Changed paths:
    M clang/include/clang/Analysis/Analyses/LifetimeSafety/FactsGenerator.h
    M clang/lib/Analysis/CFG.cpp
    M clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp
    M clang/test/Sema/warn-lifetime-safety.cpp

  Log Message:
  -----------
  [CFG] Fix cleanup ordering for CXXDefaultInitExpr
 (#191786)

Fixes CFG construction for default member initializers when
`AddCXXDefaultInitExprInCtors` is enabled by correcting the execution
order of cleanups.

E.g., in 

```cpp
struct H { 
  std::string_view v = std::string("x");
  H() {}
}; 
```

Previously, destructors for temporaries in default initializers
for`std::string("x")` was sequenced _before_ the member initialization,
causing false negatives in lifetime safety analysis because the
temporary appeared to be destroyed prematurely before making to a
origin.

Resolved this by modifying `CFGBuilder::addInitializer` to defer these
cleanups to the end of the initialization full-expression.

_(AI-assisted with HITL)_



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