[cfe-commits] Fwd: Compare two DeclGroupRefs

Sean Silva silvas at purdue.edu
Fri Jul 20 15:40:09 PDT 2012


This patch seems to change a lot of lines spuriously, such as
DeclGroup::Create. Please don't do that, as it makes the patch harder
to review. To boot, namespaces are generally not indented in the
LLVM/Clang codebases.

Please review the LLVM Coding Standards
<http://llvm.org/docs/CodingStandards.html>.

> I am not sure either :) I think it makes sense to compare the sequences of the Decl* and the Decl*'s kinds.

You should be sure before you submit a patch. If you would like, we
can discuss how to define equality.

+          if (LDG[i] != RDG[i] || LDG[i]->getKind() != RDG[i]->getKind())

This is wrong. This considers two decls to be the same if they are the
same kind (note: this use of "kind" is distinct from what I was
talking about w.r.t. the DeclGroup's "kind").

--Sean Silva


On Fri, Jul 20, 2012 at 4:44 AM, Vassil Vassilev
<vasil.georgiev.vasilev at cern.ch> wrote:
> Hi Sean,
>   Thanks for your comments!
>
>
> On 07/18/2012 11:32 PM, Sean Silva wrote:
>
> Why not
>
> std::equal(LHS.begin(), LHS.end(), RHS.begin(), RHS.end())
>
> ?
>
>   Yes I can use std::equal, however I don't think I can gain much.
>
> 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.
>
>  I am actually comparing the "kind" of the DeclGroupRefs: see the part
> isSingleDecl().
>
> 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).
>
> I am not sure either :) I think it makes sense to compare the sequences of
> the Decl* and the Decl*'s kinds. I am attaching the new patch.
>
>
> --Sean Silva
>
> Vassil



More information about the cfe-commits mailing list