================
@@ -97,9 +98,22 @@ static bool areEquivalentExpr(const Expr *Left, const Expr
*Right) {
return false;
return cast<DependentScopeDeclRefExpr>(Left)->getQualifier() ==
cast<DependentScopeDeclRefExpr>(Right)->getQualifier();
- case Stmt::DeclRefExprClass:
- return cast<DeclRefExpr>(Left)->getDecl() ==
- cast<DeclRefExpr>(Right)->getDecl();
+ case Stmt::DeclRefExprClass: {
+ const auto *L = cast<DeclRefExpr>(Left);
+ const auto *R = cast<DeclRefExpr>(Right);
+
+ if (L->getDecl() != R->getDecl())
+ return false;
+
+ // Compare source-level spellings to safely differentiate sugared types.
+ std::string LStr, RStr;
+ llvm::raw_string_ostream LOS(LStr), ROS(RStr);
+
+ L->printPretty(LOS, nullptr,
L->getDecl()->getASTContext().getPrintingPolicy());
+ R->printPretty(ROS, nullptr,
R->getDecl()->getASTContext().getPrintingPolicy());
+
+ return LStr == RStr;
----------------
zeyi2 wrote:
Nit: remove the trailing whitespace
https://github.com/llvm/llvm-project/pull/198085
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits