cchen created this revision.
cchen added a reviewer: ABataev.
Herald added subscribers: cfe-commits, guansong.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
cchen retitled this revision from "[OpenMP5.0] Fix a parsing issue for the 
extended defaultmap

This patch is for fixing a possible parsing issue in the OpenMP5.0 defaultmap 
patch.

In this case: "#pragma omp target defaultmap(scalar:", the implicit-behavior 
after the parsing will..." to "[OpenMP5.0] Fix a parsing issue for the extended 
defaultmap".
cchen edited the summary of this revision.
cchen removed a subscriber: guansong.

This patch is for fixing a possible parsing issue in the OpenMP5.0 defaultmap 
patch.
In this case:

  #pragma omp target defaultmap(scalar:

the implicit-behavior after the parsing will not be 
OMPC_DEFAULTMAP_MODIFIER_unknown.
So we need to either enforce the enum value of implicit behavior to be unknown 
or modify the logic inside getOpenMPSimpleClauseType.
And we now choose to just enforce the enum value of implicit behavior to be 
unknown.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70142

Files:
  clang/lib/Parse/ParseOpenMP.cpp


Index: clang/lib/Parse/ParseOpenMP.cpp
===================================================================
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -2310,8 +2310,14 @@
       DelimLoc = ConsumeAnyToken();
   } else if (Kind == OMPC_defaultmap) {
     // Get a defaultmap modifier
-    Arg.push_back(getOpenMPSimpleClauseType(
-        Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok)));
+    unsigned Modifier = getOpenMPSimpleClauseType(
+        Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok));
+    // Set defaultmap modifier to unknown if it is either scalar, aggregate, or
+    // pointer (modifier should be either alloc, to, from, tofrom, 
firstprivate,
+    // none, or default)
+    if (Modifier < OMPC_DEFAULTMAP_MODIFIER_unknown)
+      Modifier = OMPC_DEFAULTMAP_MODIFIER_unknown;
+    Arg.push_back(Modifier);
     KLoc.push_back(Tok.getLocation());
     if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
         Tok.isNot(tok::annot_pragma_openmp_end))


Index: clang/lib/Parse/ParseOpenMP.cpp
===================================================================
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -2310,8 +2310,14 @@
       DelimLoc = ConsumeAnyToken();
   } else if (Kind == OMPC_defaultmap) {
     // Get a defaultmap modifier
-    Arg.push_back(getOpenMPSimpleClauseType(
-        Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok)));
+    unsigned Modifier = getOpenMPSimpleClauseType(
+        Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok));
+    // Set defaultmap modifier to unknown if it is either scalar, aggregate, or
+    // pointer (modifier should be either alloc, to, from, tofrom, firstprivate,
+    // none, or default)
+    if (Modifier < OMPC_DEFAULTMAP_MODIFIER_unknown)
+      Modifier = OMPC_DEFAULTMAP_MODIFIER_unknown;
+    Arg.push_back(Modifier);
     KLoc.push_back(Tok.getLocation());
     if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
         Tok.isNot(tok::annot_pragma_openmp_end))
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to