[cfe-commits] r80690 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/Sema/IdentifierResolver.cpp

Douglas Gregor dgregor at apple.com
Tue Sep 1 10:46:54 PDT 2009


On Sep 1, 2009, at 10:39 AM, Ted Kremenek wrote:

>
> On Sep 1, 2009, at 10:31 AM, Douglas Gregor wrote:
>
>>> Can we make pointer comparisons of DeclContext objects illegal  
>>> (e.g., a private operator== method)?
>>
>> Sadly, no :(
>>
>> An overloaded operator has to have at least on parameter of class  
>> or enumeration type (or reference to one of those). The signature  
>> we would need, e.g.,
>>
>>  private:
>>    friend bool operator==(DeclContext *, DeclContext *);
>>
>> does not qualify.
>>
>>  - Doug
>
> Ah, that's right.  Would it be possible to do this if we were using  
> DeclContext& instead of DeclContext* in all places where we referred  
> to DeclContext objects?


Yes, although I fear that might be a bit awkward to use. We're often  
walking parent contexts, lookup contexts, etc., so that DeclContext&  
wouldn't be appropriate. Now, we could do a whole-sale replacement of  
DeclContext * for a new smart pointer DeclContextPtr... then we can do  
whatever we want, including make operator== do the right thing.

	- Doug



More information about the cfe-commits mailing list