[cfe-dev] DeclarationName for C++ destructor

章磊 ioripolo at gmail.com
Tue Oct 11 00:43:34 PDT 2011


Hi Sean,

Thank you for your reply.

I want to do some check to C++ override over all the methoddecls, but
when i try to do this in FindOverridenMethod which use name lookup to
find methoddecls with the same DeclarationName, I got the problem.

According to what you say, maybe i should treat dtor(ctor,
operator...) particularly.

2011/10/11, Sean Hunt <scshunt at csclub.uwaterloo.ca>:
> On Mon, Oct 10, 2011 at 23:40, 章磊 <ioripolo at gmail.com> wrote:
>
>> Hi clang,
>>
>> After read some code relevant to DeclarationName, i have a little
>> problem about it.
>>
>> For some C++ destructor(compile generated?), the base class (have some
>> virtual member) destructor and the derived class destructor have the
>> same DeclarationName.
>>
>> Examples:
>>
>> class base {
>>
>>  virtual void foo() const {}
>>
>> };
>>
>>
>>
>> class child: public base {
>>
>>  void foo() {}
>>
>> };
>>
>> if i use LookupPtr to find declarations in the base class with the
>> derived class destructor's DeclarationName, i will get the base class
>> destructor. Is this expected? If so,  what does this for?
>>
>
> That doesn't sound quite right, but in any case, you shouldn't be using name
> lookup to find a destructor. Use Sema::LookupDestructor instead.
>
> Sean
>


-- 
Best regards!

Lei Zhang




More information about the cfe-dev mailing list