<div>Why not</div><div><br></div><div>std::equal(LHS.begin(), LHS.end(), RHS.begin(), RHS.end())</div><div><br></div><div>?</div><div><br></div><div>You may also want factor in if they are the same "kind" of DeclGroupRef (i.e. isSingleDecl vs. isDeclGroup). Once you have that, then just compare appropriately.</div>
<div><br></div><div>I'm not sure exactly how best to define the equality on DeclGroupRefs. One possibility is "they represent the same sequence of Decl*'s", in which case, the std::equal solution should be correct (maybe needing an isNull() check).</div>
<div><br></div><div>--Sean Silva<br><br><div class="gmail_quote">On Wed, Jul 18, 2012 at 4:16 AM, Vassil Vassilev <span dir="ltr"><<a href="mailto:vasil.georgiev.vasilev@cern.ch" target="_blank">vasil.georgiev.vasilev@cern.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    ping...<div><div class="h5"><br>
    <div><br>
      <br>
      -------- Original Message --------
      <table border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <th align="RIGHT" nowrap valign="BASELINE">Subject:
            </th>
            <td>Compare two DeclGroupRefs</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap valign="BASELINE">Date: </th>
            <td>Mon, 16 Jul 2012 10:01:22 +0200</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap valign="BASELINE">From: </th>
            <td>Vassil Vassilev <a href="mailto:vasil.georgiev.vasilev@cern.ch" target="_blank"><vasil.georgiev.vasilev@cern.ch></a></td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap valign="BASELINE">To: </th>
            <td><a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank"><cfe-dev@cs.uiuc.edu></a></td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <pre>Hello devs,
  I need to compare two clang::DeclGroupRefs. Could somebody have a 
look into that patch and see whether I am doing it right?
Thanks a lot!
Vassil

Index: ../clang/include/clang/AST/DeclGroup.h
===================================================================
--- ../clang/include/clang/AST/DeclGroup.h    (revision 160041)
+++ ../clang/include/clang/AST/DeclGroup.h    (working copy)
@@ -128,6 +128,29 @@
     X.D = static_cast<Decl*>(Ptr);
     return X;
   }
+
+  /// operator== - Determine whether the specified DeclGroupRefs are 
identical.
+  ///
+  friend bool operator==(const DeclGroupRef LHS, const DeclGroupRef RHS) {
+    if (LHS.D == RHS.D) {
+      if (LHS.isSingleDecl() && RHS.isSingleDecl())
+        return true;
+
+      if (LHS.isDeclGroup() && RHS.isDeclGroup()){
+        const DeclGroup &LDG = LHS.getDeclGroup();
+        const DeclGroup &RDG = RHS.getDeclGroup();
+        if (LDG.size() != RDG.size())
+          return false;
+
+        for (size_t i = 0; i < LDG.size(); ++i)
+          if (LDG[i] != RDG[i])
+            return false;
+
+        return true;
+      }
+    }
+    return false;
+  }
 };

 } // end clang namespace

</pre>
      <br>
      <br>
    </div>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>