[cfe-dev] SourceLocation comparisons

Sean Silva chisophugis at gmail.com
Thu Sep 11 13:16:43 PDT 2014


On Thu, Sep 11, 2014 at 11:46 AM, Robert Ankeney <rrankene at gmail.com> wrote:

> There are times I find it useful to compare two SourceLocations in the
> same file. I've noticed the operators ==, != and < are all defined for
> SourceLocations, but not >, >= or <=. Is there any reason these are
> omitted? For now I'm having to make do with using getRawEncoding() to
> compare them
>

Why? You can express the other 3 with just <.

x > y <==> y < x
x >= y <==> !(x < y)
x <= y <==> !(y < x)

-- Sean Silva


> and it would make the code look cleaner to avoid this. Of course I'm
> assuming the encoded value always increases as you go through the file,
> which seems to be the case.
>
> Thanks,
> Robert Ankeney
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140911/2fabdad9/attachment.html>


More information about the cfe-dev mailing list