|[cdt-dev] tracking macro expansion|
Dear allI implemented some macro analysis using MacroExpander  and MacroExpansionTracker . Are those classes intended to be used outside of the CDT internals? To use them, I had to make some modifications to CDT: - I made the class PreprocessorMacro public (the MacroExpander constructor takes a CharArrayMap<PreprocessorMacro>). - I made MacroExpansionTracker.finish() protected so I can redefine it in my subclass (also start() and fail() probably should be protected). - I made the class TokenList public (it's used as argument to MacroExpansionTracker methods).
If MacroExpander is not intended to be used outside of the CDT internals, is there a recommended way for Macro analysis? Where possible in the AST, I want to identify nodes that were arguments to function style macros. E.g. having an AST like:
1 + 2 * 3 * 4 + 5 coming from the C code: 1 + MUL(2 * 3, 4) + 5 // with the macro: #define MUL(A, B) A * BI want to recognize that "2 * 3" comes from the macro argument A and that "4" comes from the macro argument B. This indeed works now but maybe there's a better way than what I did.
Thanks Marco  org.eclipse.cdt.internal.core.parser.scanner.MacroExpander  org.eclipse.cdt.internal.core.parser.scanner.MacroExpansionTracker
Back to the top