[cfe-dev] Define new pragma in Clang

Alex xinfinity_a at yahoo.com
Thu Dec 10 07:26:36 PST 2009


Hi all,

I would like to ask whether you can provide some information or a link to any
documentation regarding the definition of custom pragma in Clang. I understand
that the steps are modifying the parser lib/Parse/ParsePragma.cpp, adding an
action in include/clang/Parse/Action.h and a handler in Sema. But it is not as
easy as it sounds.
What I want is to have a pragma in the *.cpp file:

#pragma optimizeLoop
for(int i=0 ....)

and to obtain the LLVM IR in the *.ll file:

bb1:                                           
  %0 = load i32* %i, align 4, !pragma !0     
...


!0 = metadata !{metadata !"optimizeLoop"}




More information about the cfe-dev mailing list