RFC: Supporting macros in LLVM debug info

Let me see if I understand Richard’s proposal correctly.

ASTConsumer has today these two API functions (among others) that are used to consume AST entries:

virtual bool HandleTopLevelDecl(DeclGroupRef D);

virtual void HandleTranslationUnit(ASTContext &Ctx);

Do you suggest that we add a new API function that consumes macro AST.

virtual bool HandleTopLevelMacro(MacroGroupRef M);

And in the parseAST, it will create the Sema object but also the MacroSema object that will hold the macros.

Am I on the right direction? Or I misinterpreted your proposal?

As I see it, the question I need an answer for is:

What component will create the “MacroPPCallbacks” object? (CodeGenModule, ParseAST, MacroSema, Parser, or some other component?)

The advantage of letting the CodeGenModule creates it, is that CodeGen has access to compilation flags, Which means it can skip creating the callbacks if there is no need for macros.

The disadvantage would be that CodeGen will need to know about the preprocessor (i.e. the callbacks).

What do you think? Can we answer this question of where to create the Macro callbacks?

Regards,

Amjad