[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] Pinpointing VarDecl Location
From:       Olivier Goffart <ogoffart () kde ! org>
Date:       2014-07-28 8:11:52
Message-ID: 1653900.vVHW8JQVHB () finn
[Download RAW message or body]

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

_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic