================
@@ -454,6 +462,17 @@ void FactsGenerator::handleLifetimeEnds(const 
CFGLifetimeEnds &LifetimeEnds) {
             BL->getID(), LifetimeEnds.getTriggerStmt()->getEndLoc()));
     }
   }
+  // In loops, the back-edge can make a dead origin appear live at its
+  // pointee's ExpireFact. Expiring the origin here prevents that.
+  if (OriginList *List = getOriginsList(*LifetimeEndsVD)) {
+    for (OriginList *L = List; L; L = L->peelOuterOrigin()) {
----------------
Xazax-hun wrote:

I still think going through the list is not correct, it does not reflect the 
language semantics.

Imagine:
```
int *p; 
while (cond) {
  int **pp = &p;
} // A
```

Here, at program point `A`, we want to end the lifetime of `pp`, but the 
lifetime of `p` did not end, so it would be a mistake to generate any expire 
facts for it.

If you see false positives without this, I think we should spend more time 
understanding where those are coming from and look for what else can we do to 
make this work. 

https://github.com/llvm/llvm-project/pull/182368
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to