[clang] [LifetimeSafety] Give a lifetime-extended temporary a loan (PR #238776)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 5 03:57:35 PST 2026
================
@@ -642,12 +642,16 @@ void FactsGenerator::VisitMaterializeTemporaryExpr(
OriginList *RValMTEList = MTEList->peelOuterOrigin();
flow(RValMTEList, SubExprList, /*Kill=*/true);
OriginID OuterMTEID = MTEList->getOuterOriginID();
- if (MTE->getStorageDuration() == SD_FullExpression) {
- // Issue a loan to MTE for the storage location represented by MTE.
- const Loan *L = createLoan(FactMgr, MTE);
- CurrentBlockFacts.push_back(
- FactMgr.createFact<IssueFact>(L->getID(), OuterMTEID));
- }
+ const Loan *L = createLoan(FactMgr, MTE);
+ CurrentBlockFacts.push_back(
+ FactMgr.createFact<IssueFact>(L->getID(), OuterMTEID));
+ // A temporary extended to static or thread storage duration does not expire
+ // within the function.
+ // Thread termination is not modeled; a thread-local value used after its
+ // thread exits is not diagnosed.
+ if (MTE->getStorageDuration() == SD_Automatic)
----------------
ojhunt wrote:
yeah this is much clearer, thanks :)
https://github.com/llvm/llvm-project/pull/238776
More information about the cfe-commits
mailing list