Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] getting preprocessed tokens for an AST node

In a situation like this is it possible to explore the area between the images of 'a' and 'b' and extract '==' from there?

On Thu, Feb 4, 2016 at 1:55 PM, Nathan Ridge <zeratul976@xxxxxxxxxxx> wrote:
> I don't think it's possible to recover IToken 'x', but
> ASTName.getImageLocation() method always returns a non-null result.
> Don't know if this helps in your case.

Unfortunately not. I am after the image location, but of a token in the
*trailing* syntax of a node, not of the node itself.

The context in which this comes up is bug 371839. There, you have
a macro expansion like this:

  #define MACRO(x) x
  MACRO(a == b)

'a' and 'b' have AST nodes created from them by the parser, but '=='
does not. When we do eventually create an IASTImplicitName for the
'==', we try to compute the location by calling getTrailingSyntax() on
the 'a', finding the '==' token in the trailing syntax, and using the
token's location. This works when the operator occurs in regular code,
but not when it works in a macro expansion.


cdt-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top