[cfe-commits] r73820 - /cfe/trunk/include/clang/Basic/SourceLocation.h

Argyrios Kyrtzidis kyrtzidis at apple.com
Mon Jun 22 13:51:32 PDT 2009


Hi Ted &Doug,

On Jun 22, 2009, at 10:18 AM, Ted Kremenek wrote:

> Hi Argiris,
>
> I was looking at this patch, and it wasn't clear to me how is this
> useful?  Looking at the definition of operator<= tells me little about
> its intended semantics or when it is intended to be used.  My concern
> is that some users may expect operator<= to have some notion of line
> and column comparisons, which certainly isn't the case.  Do we really
> need to use operator overloading?  If so, could you add a comment of
> where this is intended to be used?

I was using it for some range testing in the same file but I wasn't  
aware about the source locations that macros will create.

On Jun 22, 2009, at 10:50 AM, Douglas Gregor wrote:

>
> It looks like SourceLocation already had a <, which is some kind of
> total ordering on SourceLocations that doesn't reflect their relative
> order within the translation unit. As Ted noted in an offline
> discussion about this, all source locations that come from macros will
> come later in this ordering than source locations that relate to a
> specific file/line/column. So while < is a total ordering, it's only
> really useful for using std::set or std::map, and conveys no semantic
> meaning.
>
> 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



More information about the cfe-commits mailing list