[cfe-dev] CXXBaseSpecifiers not returning same Type
Reid Kleckner
rnk at google.com
Tue Jul 1 11:27:15 PDT 2014
You can specifically check for ElaboratedType and call desugar or
getNamedType on it to get the type without the qualifier and compare those.
On Tue, Jul 1, 2014 at 11:23 AM, Daniel Dilts <diltsman at gmail.com> wrote:
> If I use either of those methods, it will also match typedefs, right? How
> would I modify that so that it doesn't match typedefs, but will match
> different nested name specifiers?
>
>
> On Tue, Jul 1, 2014 at 11:19 AM, Reid Kleckner <rnk at google.com> wrote:
>
>> Clang has both sugared and concrete types. By default, getting the type
>> of some AST node will give you information about the type as written. In
>> this case, two different nested name specifiers were used, so there are two
>> different types.
>>
>> If you want to compare types for equivalence, use the canonical types, or
>> simply use ASTContext::hasSameType(QualType, QualType).
>>
>>
>> On Tue, Jul 1, 2014 at 11:02 AM, Daniel Dilts <diltsman at gmail.com> wrote:
>>
>>> In the code below I would expect the CXXRecordDecls for BaseClass1 to
>>> have the same Type as both base class specifiers.
>>>
>>> When I use getTypeForDecl() on the CXXRecordDecls I get the same Type*.
>>> When I use getType().getTypePtr() on the two CXXBaseSpecifiers I get
>>> different a Type* for each one, neither of which is the same as the
>>> CXXRecordDecl's Type*.
>>>
>>> Namespace N {
>>> class BaseClass1;
>>> }
>>> class N::BaseClass1 {
>>> };
>>> class DerivedClass1 : public N::BaseClass1 {
>>> };
>>> class DerivedClass2 : public ::N::BaseClass1 {
>>> };
>>>
>>> This seems to indicate to me that the declared/defined class is of a
>>> different type from the base specifiers, and the base specifiers differ in
>>> type from each other.
>>>
>>> What am I doing wrong with this? I really just want to see if the
>>> CXXBaseSpecifier matches the CXXRecordDecl.
>>>
>>> _______________________________________________
>>> 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/20140701/611d2348/attachment.html>
More information about the cfe-dev
mailing list