================
@@ -44,6 +45,42 @@ static bool incrementWithoutOverflow(const APSInt &Value, 
APSInt &Result) {
   return Value < Result;
 }
 
+static bool areEquivalentDeclRefExpr(const DeclRefExpr *L,
+                                     const DeclRefExpr *R) {
+  if (L->getDecl() != R->getDecl())
+    return false;
+
+  const PrintingPolicy &Policy =
+      L->getDecl()->getASTContext().getPrintingPolicy();
+
+  if (L->hasQualifier() != R->hasQualifier())
+    return false;
+  if (L->hasQualifier()) {
+    std::string LQual, RQual;
+    llvm::raw_string_ostream LOS(LQual), ROS(RQual);
+    L->getQualifier().print(LOS, Policy);
+    R->getQualifier().print(ROS, Policy);
+    if (LQual != RQual)
+      return false;
+  }
+
+  if (L->hasExplicitTemplateArgs() != R->hasExplicitTemplateArgs())
+    return false;
+  if (L->hasExplicitTemplateArgs()) {
+    if (L->getNumTemplateArgs() != R->getNumTemplateArgs())
+      return false;
+    for (unsigned I = 0, E = L->getNumTemplateArgs(); I != E; ++I) {
+      std::string LArg, RArg;
+      llvm::raw_string_ostream LOS(LArg), ROS(RArg);
+      L->getTemplateArgs()[I].getArgument().print(Policy, LOS, true);
+      R->getTemplateArgs()[I].getArgument().print(Policy, ROS, true);
+      if (LArg != RArg)
+        return false;
+    }
----------------
zwuis wrote:

Use `llvm::equal`.

https://github.com/llvm/llvm-project/pull/198085
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to