================
@@ -54,14 +54,24 @@ inline bool IsLifetimeSafetyEnabled(Sema &S, const Decl *D)
{
return false;
}
+inline StringRef formatExpr(const Expr *E) {
+ const Expr *PureExpr = E->IgnoreImpCasts();
----------------
usx95 wrote:
Some AI-generated suggestions along these lines:
```cpp
bool shouldShowInAliasingChain(const Expr *CurExpr, const Expr *LastShownExpr) {
// Skip ParenExpr and ImplicitCastExpr as they're typically not meaningful
if (isa<ParenExpr>(CurExpr) || isa<ImplicitCastExpr>(CurExpr))
return false;
// Skip if same source range as previous expression
if (LastExpr && CurExpr->getSourceRange() == LastShownExpr->getSourceRange())
return false;
return true;
}
void reportAliasingChain(llvm::ArrayRef<const Expr *> OriginExprChain) {
StringRef IssueStr;
const Expr *LastShownExpr = nullptr;
for (const Expr *CurrExpr : reverse(OriginExprChain)) {
if (!shouldShowInAliasingChain(CurrExpr, LastShownExpr))
continue;
if (IssueStr.empty()) {
IssueStr = getDiagSubjectDescription(CurrExpr);
LastShownExpr = CurrExpr;
continue;
}
S.Diag(CurrExpr->getBeginLoc(),
diag::note_lifetime_safety_note_alias_chain)
<< CurrExpr->getSourceRange() << getDiagSubjectDescription(CurrExpr)
<< IssueStr;
LastShownExpr = CurrExpr;
}
}
```
https://github.com/llvm/llvm-project/pull/199345
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits