[cfe-commits] r73820 - /cfe/trunk/include/clang/Basic/SourceLocation.h
Chris Lattner
clattner at apple.com
Mon Jun 22 17:20:18 PDT 2009
On Jun 22, 2009, at 1:51 PM, Argyrios Kyrtzidis wrote:
>>
>> I do think we need the ability to provide a total ordering on source
>> locations that does have the semantic meaning of "source location x <
>> source location y if x occurs before y in the translation unit". I
>> suspect that this will have to be a function object that involves the
>> SourceManager to deal with comparing source locations that point into
>> macro instantiations, and it's not going to be as cheap as comparing
>> the raw encodings.
>>
>> Then, since operator< is unlikely to have a real semantic meaning, it
>> probably makes sense to remove it in favor of a function object that
>> can be used with std::set, std::map, etc.
>>
>> - Doug
>
> I will look into "correct" total ordering of source locations (and
> remove the operator overloads).
>
> Thanks to both for your feedback!
Argiris and I just discussed this. I think I convinced him that it
would be best to add an explicit "is before in the translation unit"
predicate to SourceManager that takes two SourceLocation's. I think
it is still useful to have operator< for clients that just want to use
things like std::map<SLoc, x> that don't care about the relative
ordering but care about identity.
-Chris
More information about the cfe-commits
mailing list