================
@@ -471,13 +474,50 @@ class LifetimeSafetySemaHelperImpl : public
LifetimeSafetySemaHelper {
}
std::string getDiagSubjectDescription(const Expr *E) {
+ // FIXME: Ideally, this should use IgnoreParenImpCasts().
+ // However, according to the comment on IgnoreParenImpCasts(),
+ // it is not fully equivalent to IgnoreImpCasts() + IgnoreParens().
+ // Once the FIXME in IgnoreParenImpCasts() is resolved,
+ // this can be switched to use IgnoreParenImpCasts().
+ E = E->IgnoreImpCasts()->IgnoreParens();
if (isa<MaterializeTemporaryExpr>(E))
return "local temporary object";
if (const auto *DRE = dyn_cast<DeclRefExpr>(E))
return getDiagSubjectDescription(DRE->getDecl());
// TODO: Handle other expression types.
- return "";
+ return "expression";
+ }
+
+ bool shouldShowInAliasChain(const Expr *CurrExpr, const Expr *LastExpr) {
+ CurrExpr = CurrExpr->IgnoreImpCasts()->IgnoreParens();
+ LastExpr = LastExpr->IgnoreImpCasts()->IgnoreParens();
+
+ if (CurrExpr->getSourceRange() == LastExpr->getSourceRange())
+ return false;
+ if (isa<MaterializeTemporaryExpr>(CurrExpr) &&
+ isa<MaterializeTemporaryExpr>(LastExpr))
----------------
suoyuan666 wrote:
Originally, I thought the goal was only to avoid diagnostics like `local
temporary object aliases the storage of local temporary object`, while still
allowing cases such as `local temporary object aliases the storage of local
variable 'a'` to be displayed.
However, I realize my reasoning here was a bit confused. Even if we want that
behavior, it shouldn't depend on `LastExpr` in the first place.
That's my mistake. I'll change the implementation to only inspect `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