[clang] [LifetimeSafety] Suggest lifetime annotations (PR #169767)
Kashika Akhouri via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 27 22:57:33 PST 2025
================
@@ -31,7 +31,7 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, LoanID ID) {
struct AccessPath {
const clang::ValueDecl *D;
- AccessPath(const clang::ValueDecl *D) : D(D) {}
+ AccessPath(const clang::ValueDecl *D = nullptr) : D(D) {}
----------------
kashika0112 wrote:
I have added a bool flag in Loan struct called `IsPlaceholderLoan` and we are not creating ExpireFacts for the loan if it is a placeholder loan in `handleLifetimeEnds`. The generated Facts look like this:
```
Function: foo
Block B2:
Issue (0 (Path: a) (Placeholder loan), ToOrigin: 0 (Decl: a))
End of Block
Block B1:
Use (0 (Decl: a), Read)
OriginFlow (Dest: 1 (Expr: ImplicitCastExpr), Src: 0 (Decl: a))
OriginFlow (Dest: 2 (Expr: CXXConstructExpr), Src: 1 (Expr: ImplicitCastExpr))
OriginEscapes (2 (Expr: CXXConstructExpr))
End of Block
Block B0:
End of Block
```
https://github.com/llvm/llvm-project/pull/169767
More information about the cfe-commits
mailing list