[cfe-dev] Missing info in macro expansion chain

Argyrios Kyrtzidis kyrtzidis at apple.com
Sat Feb 25 11:25:23 PST 2012


On Feb 25, 2012, at 3:38 AM, Chandler Carruth wrote:

> On Sat, Feb 25, 2012 at 3:18 AM, Abramo Bagnara <abramo.bagnara at gmail.com> wrote:
> In the source below I need to be able to detect that the token 4 has
> been expanded by body of macro z, but I'm unable to do that.
> 
> Asking for immediate expansion range of expanded location I get a
> MacroArgExpansion loc for argument x whose immediate expansion range is
> macro p.
> 
> Can you clarify exactly what it is you're doing? This information is there to be dug out. You can see that it is preserved and that we use it in the caret diagnostics, check out the very first test in test/Misc/caret-diags-macro.c which should be exactly the same as your case.
> 
> You'll likely need to combine getting the immediate expansion w/ getting the immediate spelling location and then getting its expansion in order to alternate between tracing the argument down and the text the user wrote.
> 
> The code that does this in diagnostics is DiagnosticRenderer::emitMacroExpansionsAndCarets (and its associated helper routines).

Also check out Lexer::getImmediateMacroName().

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120225/8279b698/attachment.html>


More information about the cfe-dev mailing list