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

> 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.

Thanks,
Nate
 		 	   		  

Back to the top