pragma and function insertion

Dear community,

For my project, I defined a #pragma and i would like clang to replace this pragma by a function call.

After reading tutorials, I managed to write a plugin which is able to parse and recognize this pragma.

Now I have some difficulties to transform this pragma into a function call.

My comprehension is that I need first to declare a new annotation token and insert it in the stream.

Then I should process this token and call the function I want.
Is this approach correct? Can a frontendAction do this job?

However, I have the feeling this process should be very common and probably the solution is already written somewhere … Does anybody have a similar example?

Thanks a lot !

Hi,

several OpenMP directives do this, such as #pragma omp flush. It's
handling is in StmtOpenMP.cpp (OMPFlushDirective) and
CGOpenMPRuntime.cpp (CGOpenMPRuntime::emitFlush)

Michael