Author: Valentin Clement
Date: 2020-06-25T09:18:54-04:00
New Revision: 5b9ce07a761f7d62ad793f9827750243de597215

URL: 
https://github.com/llvm/llvm-project/commit/5b9ce07a761f7d62ad793f9827750243de597215
DIFF: 
https://github.com/llvm/llvm-project/commit/5b9ce07a761f7d62ad793f9827750243de597215.diff

LOG: [openmp] Use Directive_enumSize instead of OMPD_unknown position

Summary:
Previously OMPD_unknown was last item in the Directive enumeration and its 
position was
used in various comparison and assertion. With the new Directive enumeration, 
this should be
change with  llvm::omp::Directive_enumSize. This patch fix two place where it 
was not done in
D81736.

Reviewers: vdmitrie, jdoerfert, jdenny

Reviewed By: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82518

Added: 
    

Modified: 
    clang/lib/Basic/OpenMPKinds.cpp
    clang/lib/Parse/ParseOpenMP.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index a000e4dee3b8..87d2c4b5a056 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -580,7 +580,7 @@ bool 
clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind) {
 void clang::getOpenMPCaptureRegions(
     SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
     OpenMPDirectiveKind DKind) {
-  assert(DKind <= OMPD_unknown);
+  assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
   switch (DKind) {
   case OMPD_parallel:
   case OMPD_parallel_for:

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 546a265cff85..9fa57d8c9791 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -194,8 +194,9 @@ static OpenMPDirectiveKindExWrapper 
parseOpenMPDirectiveKind(Parser &P) {
       DKind = F[I][2];
     }
   }
-  return DKind < OMPD_unknown ? static_cast<OpenMPDirectiveKind>(DKind)
-                              : OMPD_unknown;
+  return unsigned(DKind) < llvm::omp::Directive_enumSize
+             ? static_cast<OpenMPDirectiveKind>(DKind)
+             : OMPD_unknown;
 }
 
 static DeclarationName parseOpenMPReductionId(Parser &P) {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to