saghir created this revision.
saghir added reviewers: cfe-commits, ABataev, kkwli0.
saghir added a project: OpenMP.
Herald added a subscriber: guansong.

In the below statement in ParseOpenMP.cpp:

bool IsComma =
1942 (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
1943 Kind != OMPC_in_reduction && Kind != OMPC_depend && Kind != OMPC_map) ||
1944 (Kind == OMPC_reduction && !InvalidReductionId) ||
1945 (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown &&
1946 (!MapTypeModifierSpecified ||
1947 Data.MapTypeModifier == OMPC_MAP_always)) ||
1948 (Kind == OMPC_depend && Data.DepKind != OMPC_DEPEND_unknown);

Whenever a map type modifier is specified, the flag MapTypeModifierSpecified is 
set to true.

In the above statement,

1. when there is no map type modifier specified, !MapTypeModifierSpecified 
portion evaluates to true.
2. when the map type modifier is specified, Data.MapTypeModifier == 
OMPC_MAP_always is set to true.

So whether a modifier is specified or not, the condition (highlighted in bold) 
always evaluates to true.

Check for this condition is redundant. Consequently, declaration and all uses 
of MapTypeModifierSpecified should be removed.


Repository:
  rC Clang

https://reviews.llvm.org/D54638

Files:
  clang/lib/Parse/ParseOpenMP.cpp


Index: clang/lib/Parse/ParseOpenMP.cpp
===================================================================
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1775,7 +1775,6 @@
                                 OpenMPVarListDataTy &Data) {
   UnqualifiedId UnqualifiedReductionId;
   bool InvalidReductionId = false;
-  bool MapTypeModifierSpecified = false;
 
   // Parse '('.
   BalancedDelimiterTracker T(*this, tok::l_paren, 
tok::annot_pragma_openmp_end);
@@ -1878,8 +1877,6 @@
           if (Data.MapTypeModifier != OMPC_MAP_always) {
             Diag(Tok, diag::err_omp_unknown_map_type_modifier);
             Data.MapTypeModifier = OMPC_MAP_unknown;
-          } else {
-            MapTypeModifierSpecified = true;
           }
 
           ConsumeToken();
@@ -1904,8 +1901,6 @@
           if (Data.MapTypeModifier != OMPC_MAP_always) {
             Diag(Tok, diag::err_omp_unknown_map_type_modifier);
             Data.MapTypeModifier = OMPC_MAP_unknown;
-          } else {
-            MapTypeModifierSpecified = true;
           }
 
           ConsumeToken();
@@ -1942,9 +1937,7 @@
       (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
        Kind != OMPC_in_reduction && Kind != OMPC_depend && Kind != OMPC_map) ||
       (Kind == OMPC_reduction && !InvalidReductionId) ||
-      (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown &&
-       (!MapTypeModifierSpecified ||
-        Data.MapTypeModifier == OMPC_MAP_always)) ||
+      (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown) ||
       (Kind == OMPC_depend && Data.DepKind != OMPC_DEPEND_unknown);
   const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
   while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&


Index: clang/lib/Parse/ParseOpenMP.cpp
===================================================================
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1775,7 +1775,6 @@
                                 OpenMPVarListDataTy &Data) {
   UnqualifiedId UnqualifiedReductionId;
   bool InvalidReductionId = false;
-  bool MapTypeModifierSpecified = false;
 
   // Parse '('.
   BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
@@ -1878,8 +1877,6 @@
           if (Data.MapTypeModifier != OMPC_MAP_always) {
             Diag(Tok, diag::err_omp_unknown_map_type_modifier);
             Data.MapTypeModifier = OMPC_MAP_unknown;
-          } else {
-            MapTypeModifierSpecified = true;
           }
 
           ConsumeToken();
@@ -1904,8 +1901,6 @@
           if (Data.MapTypeModifier != OMPC_MAP_always) {
             Diag(Tok, diag::err_omp_unknown_map_type_modifier);
             Data.MapTypeModifier = OMPC_MAP_unknown;
-          } else {
-            MapTypeModifierSpecified = true;
           }
 
           ConsumeToken();
@@ -1942,9 +1937,7 @@
       (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
        Kind != OMPC_in_reduction && Kind != OMPC_depend && Kind != OMPC_map) ||
       (Kind == OMPC_reduction && !InvalidReductionId) ||
-      (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown &&
-       (!MapTypeModifierSpecified ||
-        Data.MapTypeModifier == OMPC_MAP_always)) ||
+      (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown) ||
       (Kind == OMPC_depend && Data.DepKind != OMPC_DEPEND_unknown);
   const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
   while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to