From cfe-dev Mon Jul 28 08:11:52 2014 From: Olivier Goffart Date: Mon, 28 Jul 2014 08:11:52 +0000 To: cfe-dev Subject: Re: [cfe-dev] Pinpointing VarDecl Location Message-Id: <1653900.vVHW8JQVHB () finn> X-MARC-Message: https://marc.info/?l=cfe-dev&m=140653563604107 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