================
@@ -153,34 +150,31 @@ class LifetimeChecker {
MovedExpr = *ME;
LivenessMap Origins = LiveOrigins.getLiveOriginsAt(EF);
- Confidence CurConfidence = Confidence::None;
// The UseFact or OriginEscapesFact most indicative of a lifetime error,
// prioritized by earlier source location.
- llvm::PointerUnion<const UseFact *, const OriginEscapesFact *>
- BestCausingFact = nullptr;
+ llvm::PointerUnion<const UseFact *, const OriginEscapesFact *> CausingFact
=
+ nullptr;
for (auto &[OID, LiveInfo] : Origins) {
LoanSet HeldLoans = LoanPropagation.getLoans(OID, EF);
if (!HeldLoans.contains(ExpiredLoan))
continue;
- // Loan is defaulted.
- Confidence NewConfidence = livenessKindToConfidence(LiveInfo.Kind);
- if (CurConfidence < NewConfidence) {
- CurConfidence = NewConfidence;
- BestCausingFact = LiveInfo.CausingFact;
- }
+
+ if (!CausingFact ||
+ GetFactLoc(LiveInfo.CausingFact) < GetFactLoc(CausingFact))
+ CausingFact = LiveInfo.CausingFact;
}
- if (!BestCausingFact)
- return;
- // We have a use-after-free.
- Confidence LastConf = FinalWarningsMap.lookup(ExpiredLoan).ConfidenceLevel;
- if (LastConf >= CurConfidence)
----------------
usx95 wrote:
Not sure I complete get the concern. The liveness confidence allows us to
differentiate guaranteed execution path (use dominates expiry) from possible
execution path (an expiry may be followed by a use in some control flow path).
In practice I have seen this is a comparitively low in number. E.g. this is now
a permissive warning now:
```cpp
std::string_view p;
if (cond) { p = std::string("temp"); }
if (!cond) { std::cout << p; }
```
https://github.com/llvm/llvm-project/pull/182709
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits