[cfe-dev] Getting the location of the identifier in TagDecl and RecordDecl

Yang Chen chenyang at cs.utah.edu
Fri May 25 12:13:41 PDT 2012

You may want to use getLocation().

Also, in your example, seems using tok::identifier with 
getLocForEndOfToken is more appropriate?

- Yang

On 5/25/12 1:00 PM, Lukhnos Liu wrote:
> Hi,
> How can one get the location of the identifier of a TagDecl or RecordDecl?
> For example, if I have "enum Foo { ... }" and have a TagDecl *T. T->getLocStart() returns the beginning location of the token "enum". I tried to use Lexer::findLocationAfterToken with that location and tok::kw_enum but that gives me an invalid location. Preprocessor::getLocForEndOfToken() with that start location returns the location right after the token "enum", but not the start of "Foo". The reason I'm not using getName() or type information is that I want to replace "Foo" with some other things, hence the need for source locations.
> Thanks!
> Lukhnos
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

More information about the cfe-dev mailing list