================
@@ -664,20 +665,44 @@ class LifetimeSafetySemaHelperImpl : public
LifetimeSafetySemaHelper {
return CurrExpr->getSourceRange() != LastExpr->getSourceRange();
}
- void reportAliasingChain(llvm::ArrayRef<const Expr *> OriginExprChain) {
+ void reportAliasingChain(llvm::ArrayRef<AliasChainEntry> OriginExprChain) {
if (OriginExprChain.empty())
return;
- const Expr *LastExpr = OriginExprChain.back();
+ AliasChainEntry Last = OriginExprChain.back();
+ const Expr *LastExpr = Last.E;
std::string IssueStr = getDiagSubjectDescription(LastExpr);
- for (const Expr *CurrExpr : reverse(OriginExprChain.drop_back())) {
- if (!shouldShowInAliasChain(CurrExpr, LastExpr))
+ for (AliasChainEntry Curr : reverse(OriginExprChain.drop_back())) {
+ const Expr *CurrExpr = Curr.E;
+ if (!shouldShowInAliasChain(CurrExpr, LastExpr)) {
+ if (!Last.LifetimeBound && Curr.LifetimeBound)
+ Last.LifetimeBound = Curr.LifetimeBound;
continue;
- S.Diag(CurrExpr->getBeginLoc(),
- diag::note_lifetime_safety_aliases_storage)
- << CurrExpr->getSourceRange() << getDiagSubjectDescription(CurrExpr)
- << IssueStr;
+ }
+ if (Last.LifetimeBound) {
+ std::string LifetimeBoundSubject;
+ if (Last.LifetimeBound->IsImplicitObject) {
+ LifetimeBoundSubject = "the implicit object parameter";
+ } else {
+ LifetimeBoundSubject = "parameter ";
+ if (Last.LifetimeBound->Param &&
+ Last.LifetimeBound->Param->getIdentifier())
+ LifetimeBoundSubject +=
+ "'" + Last.LifetimeBound->Param->getNameAsString() + "'";
----------------
NeKon69 wrote:
If it's not `IsImplicitObject` shouldn't it always be `Param`? I think that
instead of the first condition here we want an assert.
https://github.com/llvm/llvm-project/pull/206337
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits