[cfe-dev] [LLVMdev] [Openmp-dev] Clang Plugin to analyze OpenMP AST
Bataev, Alexey
a.bataev at gmx.com
Wed Dec 10 02:03:29 PST 2014
Hi Simone,
You don't need to analyze all children of the openmp construct, you need
to analyze only the first one. All other children maybe just some
special helper expressions/statements, not actually a construct under
OpenMP directive.
To get the position of the whole OpenMP construct you need to get
startloc of the OpenMP directive itself and endloc of the associated
stmt under this OpenMP directive, i.e. endloc of the first child of
OpenMP directive.
Best regards,
Alexey Bataev
=============
Software Engineer
Intel Compiler Team
Intel Corp.
09.12.2014 18:53, Simone Atzeni пишет:
> Hi,
>
> I am writing a plugin to get information about the OpenMP constructs from the AST.
> I am basically writing a “RecursiveASTVisitor” and I am trying to find the OpenMP statement and get information like filename and line of code.
>
> When I am visiting recursively each statement I have my own switch on the “StmtClass” and for now I am focusing on “OMPParallelForDirectiveClass”.
> In my understanding, once I find the beginning of the OpenMP statement, its children are all the statement inside the OpenMP construct.
> I was wondering if there is a way to know the lines of code where the OpenMP construct starts and where it finishes (in terms of lines of code), and then get the the same information for their children (lines of code of the other statement in the OpenMP construct).
>
> In my example, once I find the OMPParallelForDirectiveClass statement I am trying to print line of code using the 3 functions getSpellingLineNumber, getExpansionLineNumber and get PresumedLineNumber using the location start and location end, however the numbers are all equal.
> Also, I am looping into its children and the last statement that I got is that one before the closed bracket of the OpenMP constructs. Can I suppose that "the line of code of the last statement + 1” is the end of the OpenMP construct? What if there are new empty line?
>
> Hope this is clear and you can give me some advice.
>
> Thanks.
> Best,
> Simone
>
More information about the cfe-dev
mailing list