[cfe-dev] SourceLocation comparisons

Robert Ankeney rrankene at gmail.com
Thu Sep 11 14:21:08 PDT 2014


While true, such constructs can reduce code readability. Why not complete
the set? The cost is minimal.

Thanks again,
Robert Ankeney

On Thu, Sep 11, 2014 at 1:16 PM, Sean Silva <chisophugis at gmail.com> wrote:

>
>
> 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/d84f4eb1/attachment.html>


More information about the cfe-dev mailing list