[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-09 Thread via cfe-commits

jyu2-git wrote:

The test failed is due to the change following:  I had fixed the test in 
https://github.com/llvm/llvm-project/pull/91426.

commit e74a7a9fd79a74073277471243a44527c71eb4a9
Author: Fangrui Song 
Date:   Tue May 7 09:15:52 2024 -0700

cc1: Report an error for multiple actions unless separated by 
-main-file-name (#91140)

When multiple actions are specified, the last one is used and others are
overridden. This might lead to confusion if the user is used to driver's
`-S -emit-llvm` behavior.

```
%clang_cc1 -S -emit-llvm a.c # -S is overridden
%clang_cc1 -emit-llvm -S a.c # -emit-llvm is overridden
%clang_cc1 -fsyntax-only -S a.c  # -fsyntax-only is overridden
```

However, we want to continue supporting overriding the driver action
with -Xclang:

* `clang -c -Xclang -ast-dump a.c` (`%clang -cc1 -emit-obj ...
-main-file-name a.c ... -ast-dump`)
* `clang -c -xc++ -Xclang -emit-module stl.modulemap`

As an exception, we allow -ast-dump* options to be composed together
(e.g. `-ast-dump -ast-dump-lookups` in AST/ast-dump-lookups.cpp).


https://github.com/llvm/llvm-project/pull/91141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-08 Thread Tom Weaver via cfe-commits

TomWeaver18 wrote:

Reverted in 
https://github.com/llvm/llvm-project/commit/341aecc2dd0f6debcbe9f251a6d2e8a60d327eea

https://github.com/llvm/llvm-project/pull/91141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-08 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> Greetings and hello from the UK!
> 
> it looks as though this commit caused a test failure on the following build 
> bot, is anyone able to take a look see?
> 
> https://lab.llvm.org/buildbot/#/builders/139/builds/65066
> 
> Will give it an hour for a reply before looking at a revert.
> 
> Have a great day all.

I am not looking into this, and not sure if @jyu2-git 
revert is LGTM 

https://github.com/llvm/llvm-project/pull/91141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-08 Thread Tom Weaver via cfe-commits

TomWeaver18 wrote:

Greetings and hello from the UK!

 it looks as though this commit caused a test failure on the following build 
bot, is anyone able to take a look see?

https://lab.llvm.org/buildbot/#/builders/139/builds/65066

Will give it an hour for a reply before looking at a revert.

Have a great day all.



https://github.com/llvm/llvm-project/pull/91141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/91141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka approved this pull request.


https://github.com/llvm/llvm-project/pull/91141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (jyu2-git)


Changes

… (#90885)"

This reverts commit eea81aa29848361eb5b24f24d2af643fdeb9adfd.

Also change isMapType as @vitalybuka suggested.  Hope this fix 
sanitizer build problem.

---

Patch is 29.74 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/91141.diff


4 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+5) 
- (modified) clang/lib/Parse/ParseOpenMP.cpp (+43-8) 
- (modified) clang/test/OpenMP/target_ast_print.cpp (+58) 
- (modified) clang/test/OpenMP/target_map_messages.cpp (+59-46) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index fdffb35ea0d955..44bc4e0e130de8 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1438,6 +1438,9 @@ def err_omp_decl_in_declare_simd_variant : Error<
 def err_omp_sink_and_source_iteration_not_allowd: Error<" '%0 
%select{sink:|source:}1' must be with '%select{omp_cur_iteration - 
1|omp_cur_iteration}1'">;
 def err_omp_unknown_map_type : Error<
   "incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 
'release', or 'delete'">;
+def err_omp_more_one_map_type : Error<"map type is already specified">;
+def note_previous_map_type_specified_here
+: Note<"map type '%0' is previous specified here">;
 def err_omp_unknown_map_type_modifier : Error<
   "incorrect map type modifier, expected one of: 'always', 'close', 'mapper'"
   "%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">;
@@ -1445,6 +1448,8 @@ def err_omp_map_type_missing : Error<
   "missing map type">;
 def err_omp_map_type_modifier_missing : Error<
   "missing map type modifier">;
+def err_omp_map_modifier_specification_list : Error<
+  "empty modifier-specification-list is not allowed">;
 def err_omp_declare_simd_inbranch_notinbranch : Error<
   "unexpected '%0' clause, '%1' is specified already">;
 def err_omp_expected_clause_argument
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 18ba1185ee8de7..5265d8f1922c31 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -4228,13 +4228,20 @@ bool 
Parser::parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy ) {
   return T.consumeClose();
 }
 
+static OpenMPMapClauseKind isMapType(Parser );
+
 /// Parse map-type-modifiers in map clause.
-/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list)
+/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] [map-type] : ] list)
 /// where, map-type-modifier ::= always | close | mapper(mapper-identifier) |
 /// present
+/// where, map-type ::= alloc | delete | from | release | to | tofrom
 bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
+  bool HasMapType = false;
+  SourceLocation PreMapLoc = Tok.getLocation();
+  StringRef PreMapName = "";
   while (getCurToken().isNot(tok::colon)) {
 OpenMPMapModifierKind TypeModifier = isMapModifier(*this);
+OpenMPMapClauseKind MapKind = isMapType(*this);
 if (TypeModifier == OMPC_MAP_MODIFIER_always ||
 TypeModifier == OMPC_MAP_MODIFIER_close ||
 TypeModifier == OMPC_MAP_MODIFIER_present ||
@@ -4257,6 +4264,19 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 Diag(Data.MapTypeModifiersLoc.back(), diag::err_omp_missing_comma)
 << "map type modifier";
 
+} else if (getLangOpts().OpenMP >= 60 && MapKind != OMPC_MAP_unknown) {
+  if (!HasMapType) {
+HasMapType = true;
+Data.ExtraModifier = MapKind;
+MapKind = OMPC_MAP_unknown;
+PreMapLoc = Tok.getLocation();
+PreMapName = Tok.getIdentifierInfo()->getName();
+  } else {
+Diag(Tok, diag::err_omp_more_one_map_type);
+Diag(PreMapLoc, diag::note_previous_map_type_specified_here)
+<< PreMapName;
+  }
+  ConsumeToken();
 } else {
   // For the case of unknown map-type-modifier or a map-type.
   // Map-type is followed by a colon; the function returns when it
@@ -4267,8 +4287,14 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 continue;
   }
   // Potential map-type token as it is followed by a colon.
-  if (PP.LookAhead(0).is(tok::colon))
-return false;
+  if (PP.LookAhead(0).is(tok::colon)) {
+if (getLangOpts().OpenMP >= 60) {
+  break;
+} else {
+  return false;
+}
+  }
+
   Diag(Tok, diag::err_omp_unknown_map_type_modifier)
   << (getLangOpts().OpenMP >= 51 ? (getLangOpts().OpenMP >= 52 ? 2 : 1)
  : 0)
@@ -4278,6 +4304,14 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 if (getCurToken().is(tok::comma))
   ConsumeToken();
   }
+  if 

[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-05 Thread via cfe-commits

https://github.com/jyu2-git created 
https://github.com/llvm/llvm-project/pull/91141

… (#90885)"

This reverts commit eea81aa29848361eb5b24f24d2af643fdeb9adfd.

Also change isMapType as @vitalybuka suggested.  Hope this fix sanitizer build 
problem.

>From 563c1254162d7b42fd7579514f45df326216f508 Mon Sep 17 00:00:00 2001
From: Jennifer Yu 
Date: Sun, 5 May 2024 10:44:40 -0700
Subject: [PATCH] Revert "Revert "[OpenMP][TR12] change property of map-type
 modifier." (#90885)"

This reverts commit eea81aa29848361eb5b24f24d2af643fdeb9adfd.
---
 .../clang/Basic/DiagnosticParseKinds.td   |   5 +
 clang/lib/Parse/ParseOpenMP.cpp   |  51 +++--
 clang/test/OpenMP/target_ast_print.cpp|  58 ++
 clang/test/OpenMP/target_map_messages.cpp | 105 ++
 4 files changed, 165 insertions(+), 54 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index fdffb35ea0d955..44bc4e0e130de8 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1438,6 +1438,9 @@ def err_omp_decl_in_declare_simd_variant : Error<
 def err_omp_sink_and_source_iteration_not_allowd: Error<" '%0 
%select{sink:|source:}1' must be with '%select{omp_cur_iteration - 
1|omp_cur_iteration}1'">;
 def err_omp_unknown_map_type : Error<
   "incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 
'release', or 'delete'">;
+def err_omp_more_one_map_type : Error<"map type is already specified">;
+def note_previous_map_type_specified_here
+: Note<"map type '%0' is previous specified here">;
 def err_omp_unknown_map_type_modifier : Error<
   "incorrect map type modifier, expected one of: 'always', 'close', 'mapper'"
   "%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">;
@@ -1445,6 +1448,8 @@ def err_omp_map_type_missing : Error<
   "missing map type">;
 def err_omp_map_type_modifier_missing : Error<
   "missing map type modifier">;
+def err_omp_map_modifier_specification_list : Error<
+  "empty modifier-specification-list is not allowed">;
 def err_omp_declare_simd_inbranch_notinbranch : Error<
   "unexpected '%0' clause, '%1' is specified already">;
 def err_omp_expected_clause_argument
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 18ba1185ee8de7..5265d8f1922c31 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -4228,13 +4228,20 @@ bool 
Parser::parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy ) {
   return T.consumeClose();
 }
 
+static OpenMPMapClauseKind isMapType(Parser );
+
 /// Parse map-type-modifiers in map clause.
-/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list)
+/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] [map-type] : ] list)
 /// where, map-type-modifier ::= always | close | mapper(mapper-identifier) |
 /// present
+/// where, map-type ::= alloc | delete | from | release | to | tofrom
 bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
+  bool HasMapType = false;
+  SourceLocation PreMapLoc = Tok.getLocation();
+  StringRef PreMapName = "";
   while (getCurToken().isNot(tok::colon)) {
 OpenMPMapModifierKind TypeModifier = isMapModifier(*this);
+OpenMPMapClauseKind MapKind = isMapType(*this);
 if (TypeModifier == OMPC_MAP_MODIFIER_always ||
 TypeModifier == OMPC_MAP_MODIFIER_close ||
 TypeModifier == OMPC_MAP_MODIFIER_present ||
@@ -4257,6 +4264,19 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 Diag(Data.MapTypeModifiersLoc.back(), diag::err_omp_missing_comma)
 << "map type modifier";
 
+} else if (getLangOpts().OpenMP >= 60 && MapKind != OMPC_MAP_unknown) {
+  if (!HasMapType) {
+HasMapType = true;
+Data.ExtraModifier = MapKind;
+MapKind = OMPC_MAP_unknown;
+PreMapLoc = Tok.getLocation();
+PreMapName = Tok.getIdentifierInfo()->getName();
+  } else {
+Diag(Tok, diag::err_omp_more_one_map_type);
+Diag(PreMapLoc, diag::note_previous_map_type_specified_here)
+<< PreMapName;
+  }
+  ConsumeToken();
 } else {
   // For the case of unknown map-type-modifier or a map-type.
   // Map-type is followed by a colon; the function returns when it
@@ -4267,8 +4287,14 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 continue;
   }
   // Potential map-type token as it is followed by a colon.
-  if (PP.LookAhead(0).is(tok::colon))
-return false;
+  if (PP.LookAhead(0).is(tok::colon)) {
+if (getLangOpts().OpenMP >= 60) {
+  break;
+} else {
+  return false;
+}
+  }
+
   Diag(Tok, diag::err_omp_unknown_map_type_modifier)
   << (getLangOpts().OpenMP >= 51 ? (getLangOpts().OpenMP >= 52 ? 2 : 1)