================
@@ -470,10 +470,28 @@ void FactsGenerator::VisitLambdaExpr(const LambdaExpr
*LE) {
}
}
+bool FactsGenerator::isEscapingOrigin(OriginID OID) const {
+ return llvm::any_of(EscapesInCurrentBlock, [OID](const Fact *F) {
+ if (const auto *EF = F->getAs<OriginEscapesFact>())
+ return EF->getEscapedOriginID() == OID;
+ return false;
+ });
+}
+
void FactsGenerator::handleLifetimeEnds(const CFGLifetimeEnds &LifetimeEnds) {
const VarDecl *LifetimeEndsVD = LifetimeEnds.getVarDecl();
if (!LifetimeEndsVD)
return;
+ // In loops, the back-edge can make a dead origin appear live at its
+ // pointee's ExpireFact. Expiring the origin prevents that.
+ std::optional<OriginID> ExpiredOID;
+ if (OriginList *List = getOriginsList(*LifetimeEndsVD)) {
+ OriginID OID = List->getOuterOriginID();
+ // Skip if this origin escapes. Its loans are still needed
+ // for the escape checker.
+ if (!isEscapingOrigin(OID))
----------------
aeft wrote:
Without `isEscapingOrigin` check, `return_ref_to_local_ptr_pointing_to_local`
fails.
https://github.com/llvm/llvm-project/pull/182368
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits