I am trying to add a new #pragma for certain call-sites of a C/C++ program. For example,
a = foo(1, 2);
I have been able extend clang to add a pragma handler that has a callback on the Sema actions. That’s the easy part.
In Sema action implementation, I want to ensure that this indeed is a call statement. So,
Is there is any boilerplate code (or guidelines) to ensure that the “pragma” following statement is indeed a call statement.
What would be an efficient way to carry extra information from this Sema action implementation to the CodeGen for this call statement/expression (ie, CGStmt.cpp)? I would like to carry more information than just a flag. It seems a waste to add an extra pointer to Stmt class for this.
I understand that CGStmt.cpp is the top level code generator for statements. Any clue on what path (or function) is taken for a call-site expression? I need this to emit extra code related to the my pragma.
(Note, this is my first time hacking on clang! Thanks!)