[cfe-dev] Source to source for reduction clause - clang

Masoud Ataei via cfe-dev cfe-dev at lists.llvm.org
Wed May 17 11:25:15 PDT 2017


Hello,

I am new to clang and this problem may be so easy, but it took lots of my
time. I am writing a source to source translator by clang for translating
from my MetaFork language to OpenMP. I want to translate:
----------------------------------
meta_for reduction[+: var] (int i=0; i<10; i++)

to

#pragma omp parallel for reduction (+: var)
           for (int i=0; i< 10; i++)
----------------------------------
What I did to this point, I defined "meta_for" to be "#pragma omp parallel
for for" and managed to add a "tok::eod" between two for's in preprocessor.
So now, I can translate
----------------------------------
meta_for (int i=0; i<10; i++)

to

#pragma omp parallel for
           for (int i=0; i< 10; i++)
----------------------------------

But when I add reduction clause to meta_for, my idea is to comment out
" reduction[+: var]" and have a complete parallel for loop, also save the
location of reduction clause and operation and variables for later. But
when I change the token kind of "reduction", "[", ... , "]" to
tok::comment. It gives me a weird error.

It says  expected to have ")" after "int" to be matched with "("!!!

can anyone help me on that?

Thank you.

-- 
------
----------
Masoud Ataei (Mr.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170517/5aad924c/attachment.html>


More information about the cfe-dev mailing list