Question

I have a compiler plugin that operates after the typer phase. The plugin needs to ignore any code that was generated from a macro. (I am having some problem with range positioning, and the easiest fix I think is to just ignore macro code, I don't need to process it in my plugin anyway).

So, what I would like to do is detect whether some code was macro expanded. Is that possible? Is there some flag hidden in the tree somewhere?

Or alternatively, I would be happy with the ability in a previous phase to detect if some code is going to be macro expanded, and then I could annotate it so I can detect later.

Was it helpful?

Solution

There is a MacroExpansionAttachment.

A sample usage, as I recall.

OTHER TIPS

While waiting for a better solution, my current workaround is to detect any Trees that do not have a range position (I have Yrangepos enabled). This detects generated code, including macros.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top