[cfe-dev] Pinpointing VarDecl Location
Olivier Goffart
ogoffart at kde.org
Mon Jul 28 01:11:52 PDT 2014
On Friday 25 July 2014 09:04:19 Uri Mann wrote:
> Hello All;
>
> Given:
> void f() {
> int a, b, c;
> }
>
> I'm wondering if there's a way to find the SourceLocation and/or SourceRange
> of a, b and c? Using VarDecl::getSourceRange(), VarDecl::getStartLoc(), etc
> I get the same values for all instance between the type (int) and the ;.
>
> Using the Lexer::LexFromRawLexer() is tedious and error prone. Any
> suggestions?
Hi Uri,
On top of my head, I think you should use VarDecl::getLocation() which points
to the location of the name token. And since it is AFAIK always only one
token, it should be enough. (The end of the range may include the
initializers).
--
Olivier
More information about the cfe-dev
mailing list