LLVM Discussion Forums

[clang] Parse additional tokens after #pragma

Hi All,

I am using clang::PPCallbacks to parse custom #pragma’s in a C source file. My plan is
to have custom pragma’s similar to following which will provide additional info about how to
generate optimal code for loops.

#pragma for simd(32)
for(int i=0; i<64; i++){
  a[i] = i

I implemented a clang::ASTFrontendAction which adds a callback to my custom pragma
handler with clang::Preprocessor::addPPCallbacks(). My program successfully calls the
following callback function from clang::PPCallback once the preprocessor encounters a
#pragma directive:

clang::PPCallbacks::PragmaDirective(clang::SourceLocation Loc, clang::PragmaIntroducerKind Introducer);

My question is how can I get the next two tokens i.e., for and simd(32) in the above
example once I am inside this callback function.

Thank you very much in advance !!