================
@@ -254,7 +254,22 @@ class LifetimeChecker {
SourceLocation ExpiryLoc = Warning.ExpiryLoc;
if (const auto *UF = CausingFact.dyn_cast<const UseFact *>()) {
- if (Warning.InvalidatedByExpr) {
+ // An implicit use has no source expression; anchor diagnostics at its
+ // location.
+ if (UF->isImplicit()) {
+ if (Warning.InvalidatedByExpr) {
+ if (IssueExpr)
+ SemaHelper->reportUseAfterInvalidation(
+ IssueExpr, UF->getImplicitLoc(), Warning.InvalidatedByExpr);
+ else if (InvalidatedPVD)
+ SemaHelper->reportUseAfterInvalidation(InvalidatedPVD,
+ UF->getImplicitLoc(),
+
Warning.InvalidatedByExpr);
+ } else
+ SemaHelper->reportUseAfterScope(
+ IssueExpr, UF->getImplicitLoc(), MovedExpr, ExpiryLoc,
+ getExprChain(LoanPropagation.buildOriginFlowChain(UF, LID)));
----------------
NeKon69 wrote:
I think by the LLVM coding standard this should be something like this instead
(braces around else)
```cpp
} else {
SemaHelper->reportUseAfterScope(
IssueExpr, UF->getImplicitLoc(), MovedExpr, ExpiryLoc,
getExprChain(LoanPropagation.buildOriginFlowChain(UF, LID)));
}
} else if (Warning.InvalidatedByExpr) {
```
https://github.com/llvm/llvm-project/pull/204650
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits