renaming a Type

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

renaming a Type

Vladimir Kirillov
Hello, cfe-dev!

I'm using a clang to index the types used all over the code.
I'm having a custom anonymous types naming scheme used in the code,
so I want to rename the anonymous types to conform that scheme.

For instance, consider the following type:
struct parent::<anonymous at tests/a.c:4:2>

I want to rename the <anonymous ...> part (actually let the type
identifier have something in it's name field).

I took a brief look into the IdentifierInfo and TypePrinter,
but the IdentifierInfo::getNameStart() method uses some weird
identifier lookups, so i'm asking for help here.

Please, explain me how to do it the best way :-).


Thanks!
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: renaming a Type

John McCall
On Aug 27, 2010, at 4:40 AM, Vladimir Kirillov wrote:
> I took a brief look into the IdentifierInfo and TypePrinter,
> but the IdentifierInfo::getNameStart() method uses some weird
> identifier lookups, so i'm asking for help here.

The ASTContext has a reference to the IdentifierTable, which has
IdentifierTable::get(...).  I think that's what you're looking for.

John.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: renaming a Type

Vladimir Kirillov
On 10:03 Fri 27 Aug, John McCall wrote:
> On Aug 27, 2010, at 4:40 AM, Vladimir Kirillov wrote:
> > I took a brief look into the IdentifierInfo and TypePrinter,
> > but the IdentifierInfo::getNameStart() method uses some weird
> > identifier lookups, so i'm asking for help here.
>
> The ASTContext has a reference to the IdentifierTable, which has
> IdentifierTable::get(...).  I think that's what you're looking for.

Right. Assuming I have looked up the type's IdentifierInfo, how to
change the name of this type in a proper way? Is there anything like
IdentifierInfo::setName()?
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: renaming a Type

John McCall

On Aug 27, 2010, at 3:48 PM, Vladimir Kirillov wrote:

> On 10:03 Fri 27 Aug, John McCall wrote:
>> On Aug 27, 2010, at 4:40 AM, Vladimir Kirillov wrote:
>>> I took a brief look into the IdentifierInfo and TypePrinter,
>>> but the IdentifierInfo::getNameStart() method uses some weird
>>> identifier lookups, so i'm asking for help here.
>>
>> The ASTContext has a reference to the IdentifierTable, which has
>> IdentifierTable::get(...).  I think that's what you're looking for.
>
> Right. Assuming I have looked up the type's IdentifierInfo, how to
> change the name of this type in a proper way? Is there anything like
> IdentifierInfo::setName()?

An IdentifierInfo *is* a name.  You need the set the name of the TypeDecl,
which you do by calling setDeclName with a different IdentifierInfo (or to
be precise, with a DeclarationName based on a different IdentifierInfo).

John.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev