r255875 - Add QualType case to operator< for DynTypedNode.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 17 05:47:31 PST 2015


On Wed, Dec 16, 2015 at 11:46 PM, Richard Trieu via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: rtrieu
> Date: Wed Dec 16 22:46:48 2015
> New Revision: 255875
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255875&view=rev
> Log:
> Add QualType case to operator< for DynTypedNode.
>
> This allows sorting DynTypedNode's which are QualType's since QualType does
> not have memoization.
>
> Modified:
>     cfe/trunk/include/clang/AST/ASTTypeTraits.h
>
> Modified: cfe/trunk/include/clang/AST/ASTTypeTraits.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTTypeTraits.h?rev=255875&r1=255874&r2=255875&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/ASTTypeTraits.h (original)
> +++ cfe/trunk/include/clang/AST/ASTTypeTraits.h Wed Dec 16 22:46:48 2015
> @@ -271,6 +271,10 @@ public:
>      if (!NodeKind.isSame(Other.NodeKind))
>        return NodeKind < Other.NodeKind;
>
> +    if (ASTNodeKind::getFromNodeKind<QualType>().isSame(NodeKind))
> +      return getUnchecked<QualType>().getAsOpaquePtr() ==
> +             Other.getUnchecked<QualType>().getAsOpaquePtr();
> +

This only tests for equality, not comparison, which means operator< no
longer has a strict weak ordering. Also, there are no tests for this
change.

~Aaron

>      if (ASTNodeKind::getFromNodeKind<TypeLoc>().isSame(NodeKind)) {
>        auto TLA = getUnchecked<TypeLoc>();
>        auto TLB = Other.getUnchecked<TypeLoc>();
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list