From 5b9ce07a761f7d62ad793f9827750243de597215 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Thu, 25 Jun 2020 09:17:15 -0400 Subject: [PATCH] [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 --- clang/lib/Basic/OpenMPKinds.cpp | 2 +- clang/lib/Parse/ParseOpenMP.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp index a000e4d..87d2c4b 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 &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 546a265..9fa57d8 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(DKind) - : OMPD_unknown; + return unsigned(DKind) < llvm::omp::Directive_enumSize + ? static_cast(DKind) + : OMPD_unknown; } static DeclarationName parseOpenMPReductionId(Parser &P) { -- 2.7.4