[cfe-dev] End location of OpenMP Clauses

Alexey Bataev via cfe-dev cfe-dev at lists.llvm.org
Fri Jul 6 12:42:04 PDT 2018


Fixed in r336460

-------------
Best regards,
Alexey Bataev

05.07.2018 10:53, Cramer, Tim via cfe-dev пишет:
> Hello everybody,
>
> I have question regarding the source location of an OpenMP clause. Given the following code:
>
> int main() {
>   int n = 42;
>   int m = 23;
>   float f = 42.23;
>
>   #pragma omp target parallel map(n) num_threads(2) if(1) shared(n,m) private(f)  default(shared) proc_bind(spread)
>   {
>     f = n / m;
>   }
>
>   return 0;
> }
>
> I get the following AST (snippet):
>
>     |-OMPTargetParallelDirective 0x77aaf0 <line:6:11, col:116>
>     | |-OMPMapClause 0x7643a0 <col:31, col:38>
>     | | `-DeclRefExpr 0x764378 <col:35> 'int' lvalue Var 0x764168 'n' 'int'
>     | |-OMPNum_threadsClause 0x764420 <col:38, col:51>
>     | | `-IntegerLiteral 0x764400 <col:50> 'int' 2
>     | |-OMPIfClause 0x764468 <col:53, col:57>
>     | | `-IntegerLiteral 0x764448 <col:56> 'int' 1
>     | |-OMPSharedClause 0x7644f0 <col:59, col:71>
>     | | |-DeclRefExpr 0x7644a0 <col:66> 'int' lvalue Var 0x764168 'n' 'int'
>     | | `-DeclRefExpr 0x7644c8 <col:68> 'int' lvalue Var 0x764218 'm' 'int'
>     | |-OMPPrivateClause 0x7645e0 <col:71, col:83>
>     | | `-DeclRefExpr 0x764518 <col:79> 'float' lvalue Var 0x7642c8 'f' 'float'
>     | |-OMPDefaultClause 0x764608 <col:83, col:99>
>     | |-OMPProc_bindClause 0x764620 <col:99, col:116>
>
> As you can see, the end of the clauses 'map', 'num_threads', 'shared', 'private' point just before the start of the next token (clause). In contrast, the end of the clauses 'if', 'default' and 'proc_bind' points just before the right paren. The problem is that "clang::OMPClause::getLocEnd()" returns different locations, depending on the clause kind. I guess this does not look like intended. 
>
> My question is: Where should "clang::OMPClause::getLocEnd()" point to? After or before the left paren?
>
> A quick look into "lib/Parse/ParseOpenMP.cpp" shows that in one case "Tok.getLocation()" is used and in the other cases "T.getCloseLocation()". What is correct?
>
> Best regards,
>
> Tim Cramer
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180706/b91cc3ec/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180706/b91cc3ec/attachment.sig>


More information about the cfe-dev mailing list