[compiler-rt] d791f0c - [ORC-RT] Add equality/inequality comparison to string_view.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 2 13:43:16 PDT 2021


Is there room (readily used infrastructure, etc) for unit tests for these
primitives?

On Tue, Jun 1, 2021 at 11:26 AM Lang Hames via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

>
> Author: Lang Hames
> Date: 2021-06-01T11:24:19-07:00
> New Revision: d791f0c2199e47e63e1dd95da2e78518d574bad2
>
> URL:
> https://github.com/llvm/llvm-project/commit/d791f0c2199e47e63e1dd95da2e78518d574bad2
> DIFF:
> https://github.com/llvm/llvm-project/commit/d791f0c2199e47e63e1dd95da2e78518d574bad2.diff
>
> LOG: [ORC-RT] Add equality/inequality comparison to string_view.
>
> Added:
>
>
> Modified:
>     compiler-rt/lib/orc/adt.h
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/compiler-rt/lib/orc/adt.h b/compiler-rt/lib/orc/adt.h
> index b7d2174bc197e..33b731082f88f 100644
> --- a/compiler-rt/lib/orc/adt.h
> +++ b/compiler-rt/lib/orc/adt.h
> @@ -84,6 +84,21 @@ class string_view {
>    constexpr size_type size() const noexcept { return Size; }
>    constexpr bool empty() const noexcept { return Size == 0; }
>
> +  friend bool operator==(const string_view &LHS, const string_view &RHS) {
> +    if (LHS.Size != RHS.Size)
> +      return false;
> +    if (LHS.Data == RHS.Data)
> +      return true;
> +    for (size_t I = 0; I != LHS.Size; ++I)
> +      if (LHS.Data[I] != RHS.Data[I])
> +        return false;
> +    return true;
> +  }
> +
> +  friend bool operator!=(const string_view &LHS, const string_view &RHS) {
> +    return !(LHS == RHS);
> +  }
> +
>  private:
>    const char *Data = nullptr;
>    size_type Size = 0;
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210602/2ee10021/attachment.html>


More information about the llvm-commits mailing list