[PATCH] D49265: [Tooling] Add operator== to CompileCommand

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 16 09:47:25 PDT 2018


Any chance this can/should be unit tested? (also, in general (though might
not matter in this instance), symmetric operators like == should be
implemented as non-members (though they can still be friends and if they
are, can be defined inline in the class definition as a member could be),
so any implicit conversions apply equally to the LHS as the RHS of the
expression)

On Thu, Jul 12, 2018 at 1:48 PM Simon Marchi via Phabricator via
cfe-commits <cfe-commits at lists.llvm.org> wrote:

> simark created this revision.
> Herald added subscribers: cfe-commits, ioeric, ilya-biryukov.
>
> It does the obvious thing of comparing all fields.  This will be needed
> for a clangd patch I have in the pipeline.
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D49265
>
> Files:
>   include/clang/Tooling/CompilationDatabase.h
>
>
> Index: include/clang/Tooling/CompilationDatabase.h
> ===================================================================
> --- include/clang/Tooling/CompilationDatabase.h
> +++ include/clang/Tooling/CompilationDatabase.h
> @@ -59,6 +59,11 @@
>
>    /// The output file associated with the command.
>    std::string Output;
> +
> +  bool operator==(const CompileCommand &RHS) const {
> +    return Directory == RHS.Directory && Filename == RHS.Filename &&
> +           CommandLine == RHS.CommandLine && Output == RHS.Output;
> +  }
>  };
>
>  /// Interface for compilation databases.
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180716/45f90fe6/attachment.html>


More information about the cfe-commits mailing list