atmnpatel updated this revision to Diff 244334. atmnpatel added a comment. Removes specified values in favor of defaults in the DefaultKind enum.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74513/new/ https://reviews.llvm.org/D74513 Files: clang/include/clang/AST/OpenMPClause.h clang/include/clang/ASTMatchers/ASTMatchers.h clang/include/clang/Basic/OpenMPKinds.def clang/include/clang/Basic/OpenMPKinds.h clang/include/clang/Sema/Sema.h clang/lib/AST/OpenMPClause.cpp clang/lib/Basic/OpenMPKinds.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp llvm/include/llvm/Frontend/OpenMP/OMPConstants.h llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def =================================================================== --- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -342,6 +342,26 @@ ///} +/// Default kinds +/// +///{ + +#ifndef OMP_DEFAULT_KIND +#define OMP_DEFAULT_KIND(Enum, Str) +#endif + +#define __OMP_DEFAULT_KIND(Name) \ + OMP_DEFAULT_KIND(OMP_DEFAULT_##Name, #Name) + +__OMP_DEFAULT_KIND(none) +__OMP_DEFAULT_KIND(shared) +__OMP_DEFAULT_KIND(unknown) + +#undef __OMP_DEFAULT_KIND +#undef OMP_DEFAULT_KIND + +///} + /// Proc bind kinds /// ///{ Index: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h =================================================================== --- llvm/include/llvm/Frontend/OpenMP/OMPConstants.h +++ llvm/include/llvm/Frontend/OpenMP/OMPConstants.h @@ -49,6 +49,16 @@ #define OMP_RTL(Enum, ...) constexpr auto Enum = omp::RuntimeFunction::Enum; #include "llvm/Frontend/OpenMP/OMPKinds.def" +/// IDs for the different default kinds. +enum class DefaultKind { +#define OMP_DEFAULT_KIND(Enum, Str) Enum, +#include "llvm/Frontend/OpenMP/OMPKinds.def" +}; + +#define OMP_DEFAULT_KIND(Enum, ...) \ + constexpr auto Enum = omp::DefaultKind::Enum; +#include "llvm/Frontend/OpenMP/OMPKinds.def" + /// IDs for the different proc bind kinds. enum class ProcBindKind { #define OMP_PROC_BIND_KIND(Enum, Str, Value) Enum = Value, Index: clang/lib/Serialization/ASTWriter.cpp =================================================================== --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -6097,7 +6097,7 @@ } void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) { - Record.push_back(C->getDefaultKind()); + Record.push_back(unsigned(C->getDefaultKind())); Record.AddSourceLocation(C->getLParenLoc()); Record.AddSourceLocation(C->getDefaultKindKwLoc()); } Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -11887,8 +11887,7 @@ } void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) { - C->setDefaultKind( - static_cast<OpenMPDefaultClauseKind>(Record.readInt())); + C->setDefaultKind(static_cast<llvm::omp::DefaultKind>(Record.readInt())); C->setLParenLoc(Record.readSourceLocation()); C->setDefaultKindKwLoc(Record.readSourceLocation()); } Index: clang/lib/Sema/TreeTransform.h =================================================================== --- clang/lib/Sema/TreeTransform.h +++ clang/lib/Sema/TreeTransform.h @@ -1602,8 +1602,7 @@ /// /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. - OMPClause *RebuildOMPDefaultClause(OpenMPDefaultClauseKind Kind, - SourceLocation KindKwLoc, + OMPClause *RebuildOMPDefaultClause(DefaultKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) { Index: clang/lib/Sema/SemaOpenMP.cpp =================================================================== --- clang/lib/Sema/SemaOpenMP.cpp +++ clang/lib/Sema/SemaOpenMP.cpp @@ -12034,9 +12034,8 @@ OMPClause *Res = nullptr; switch (Kind) { case OMPC_default: - Res = - ActOnOpenMPDefaultClause(static_cast<OpenMPDefaultClauseKind>(Argument), - ArgumentLoc, StartLoc, LParenLoc, EndLoc); + Res = ActOnOpenMPDefaultClause(static_cast<DefaultKind>(Argument), + ArgumentLoc, StartLoc, LParenLoc, EndLoc); break; case OMPC_proc_bind: Res = ActOnOpenMPProcBindClause(static_cast<ProcBindKind>(Argument), @@ -12139,31 +12138,24 @@ return std::string(Out.str()); } -OMPClause *Sema::ActOnOpenMPDefaultClause(OpenMPDefaultClauseKind Kind, +OMPClause *Sema::ActOnOpenMPDefaultClause(DefaultKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) { - if (Kind == OMPC_DEFAULT_unknown) { - static_assert(OMPC_DEFAULT_unknown > 0, - "OMPC_DEFAULT_unknown not greater than 0"); + if (Kind == OMP_DEFAULT_unknown) { Diag(KindKwLoc, diag::err_omp_unexpected_clause_value) - << getListOfPossibleValues(OMPC_default, /*First=*/0, - /*Last=*/OMPC_DEFAULT_unknown) + << getListOfPossibleValues(OMPC_default, + /*First=*/unsigned(OMP_DEFAULT_none), + /*Last=*/4) << getOpenMPClauseName(OMPC_default); return nullptr; } - switch (Kind) { - case OMPC_DEFAULT_none: + if (Kind == OMP_DEFAULT_none) DSAStack->setDefaultDSANone(KindKwLoc); - break; - case OMPC_DEFAULT_shared: + else if (Kind == OMP_DEFAULT_shared) DSAStack->setDefaultDSAShared(KindKwLoc); - break; - case OMPC_DEFAULT_unknown: - llvm_unreachable("Clause kind is not allowed."); - break; - } + return new (Context) OMPDefaultClause(Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc); } Index: clang/lib/Basic/OpenMPKinds.cpp =================================================================== --- clang/lib/Basic/OpenMPKinds.cpp +++ clang/lib/Basic/OpenMPKinds.cpp @@ -104,10 +104,10 @@ StringRef Str) { switch (Kind) { case OMPC_default: - return llvm::StringSwitch<OpenMPDefaultClauseKind>(Str) -#define OPENMP_DEFAULT_KIND(Name) .Case(#Name, OMPC_DEFAULT_##Name) -#include "clang/Basic/OpenMPKinds.def" - .Default(OMPC_DEFAULT_unknown); + return llvm::StringSwitch<unsigned>(Str) +#define OMP_DEFAULT_KIND(Enum, Name) .Case(Name) +#include "llvm/Frontend/OpenMP/OMPKinds.def" + .Default(unsigned(llvm::omp::OMP_DEFAULT_unknown)); case OMPC_proc_bind: return llvm::StringSwitch<unsigned>(Str) #define OMP_PROC_BIND_KIND(Enum, Name, Value) .Case(Name, Value) @@ -247,12 +247,10 @@ switch (Kind) { case OMPC_default: switch (Type) { - case OMPC_DEFAULT_unknown: - return "unknown"; -#define OPENMP_DEFAULT_KIND(Name) \ - case OMPC_DEFAULT_##Name: \ - return #Name; -#include "clang/Basic/OpenMPKinds.def" +#define OMP_DEFAULT_KIND(Enum, Name) \ + case unsigned(Enum): \ + return Name; +#include "llvm/Frontend/OpenMP/OMPKinds.def" } llvm_unreachable("Invalid OpenMP 'default' clause type"); case OMPC_proc_bind: Index: clang/lib/AST/OpenMPClause.cpp =================================================================== --- clang/lib/AST/OpenMPClause.cpp +++ clang/lib/AST/OpenMPClause.cpp @@ -1244,7 +1244,8 @@ void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) { OS << "default(" - << getOpenMPSimpleClauseTypeName(OMPC_default, Node->getDefaultKind()) + << getOpenMPSimpleClauseTypeName(OMPC_default, + unsigned(Node->getDefaultKind())) << ")"; } Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -10272,7 +10272,7 @@ SourceLocation LParenLoc, SourceLocation EndLoc); /// Called on well-formed 'default' clause. - OMPClause *ActOnOpenMPDefaultClause(OpenMPDefaultClauseKind Kind, + OMPClause *ActOnOpenMPDefaultClause(llvm::omp::DefaultKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, Index: clang/include/clang/Basic/OpenMPKinds.h =================================================================== --- clang/include/clang/Basic/OpenMPKinds.h +++ clang/include/clang/Basic/OpenMPKinds.h @@ -73,14 +73,6 @@ OMPC_unknown }; -/// OpenMP attributes for 'default' clause. -enum OpenMPDefaultClauseKind { -#define OPENMP_DEFAULT_KIND(Name) \ - OMPC_DEFAULT_##Name, -#include "clang/Basic/OpenMPKinds.def" - OMPC_DEFAULT_unknown -}; - /// OpenMP attributes for 'schedule' clause. enum OpenMPScheduleClauseKind { #define OPENMP_SCHEDULE_KIND(Name) \ Index: clang/include/clang/Basic/OpenMPKinds.def =================================================================== --- clang/include/clang/Basic/OpenMPKinds.def +++ clang/include/clang/Basic/OpenMPKinds.def @@ -107,9 +107,6 @@ #ifndef OPENMP_DISTRIBUTE_CLAUSE #define OPENMP_DISTRIBUTE_CLAUSE(Name) #endif -#ifndef OPENMP_DEFAULT_KIND -# define OPENMP_DEFAULT_KIND(Name) -#endif #ifndef OPENMP_SCHEDULE_KIND #define OPENMP_SCHEDULE_KIND(Name) #endif @@ -365,10 +362,6 @@ // Clauses allowed for OpenMP directive 'cancel'. OPENMP_CANCEL_CLAUSE(if) -// Static attributes for 'default' clause. -OPENMP_DEFAULT_KIND(none) -OPENMP_DEFAULT_KIND(shared) - // Static attributes for 'schedule' clause. OPENMP_SCHEDULE_KIND(static) OPENMP_SCHEDULE_KIND(dynamic) @@ -1118,7 +1111,6 @@ #undef OPENMP_DEPEND_KIND #undef OPENMP_SCHEDULE_MODIFIER #undef OPENMP_SCHEDULE_KIND -#undef OPENMP_DEFAULT_KIND #undef OPENMP_CLAUSE #undef OPENMP_CRITICAL_CLAUSE #undef OPENMP_ORDERED_CLAUSE Index: clang/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchers.h +++ clang/include/clang/ASTMatchers/ASTMatchers.h @@ -7056,7 +7056,7 @@ /// /// ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``. AST_MATCHER(OMPDefaultClause, isNoneKind) { - return Node.getDefaultKind() == OMPC_DEFAULT_none; + return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_none; } /// Matches if the OpenMP ``default`` clause has ``shared`` kind specified. @@ -7071,7 +7071,7 @@ /// /// ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``. AST_MATCHER(OMPDefaultClause, isSharedKind) { - return Node.getDefaultKind() == OMPC_DEFAULT_shared; + return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_shared; } /// Matches if the OpenMP directive is allowed to contain the specified OpenMP Index: clang/include/clang/AST/OpenMPClause.h =================================================================== --- clang/include/clang/AST/OpenMPClause.h +++ clang/include/clang/AST/OpenMPClause.h @@ -866,7 +866,7 @@ SourceLocation LParenLoc; /// A kind of the 'default' clause. - OpenMPDefaultClauseKind Kind = OMPC_DEFAULT_unknown; + llvm::omp::DefaultKind Kind = llvm::omp::OMP_DEFAULT_unknown; /// Start location of the kind in source code. SourceLocation KindKwLoc; @@ -874,7 +874,7 @@ /// Set kind of the clauses. /// /// \param K Argument of clause. - void setDefaultKind(OpenMPDefaultClauseKind K) { Kind = K; } + void setDefaultKind(llvm::omp::DefaultKind K) { Kind = K; } /// Set argument location. /// @@ -889,7 +889,7 @@ /// \param StartLoc Starting location of the clause. /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. - OMPDefaultClause(OpenMPDefaultClauseKind A, SourceLocation ALoc, + OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) : OMPClause(OMPC_default, StartLoc, EndLoc), LParenLoc(LParenLoc), @@ -906,7 +906,7 @@ SourceLocation getLParenLoc() const { return LParenLoc; } /// Returns kind of the clause. - OpenMPDefaultClauseKind getDefaultKind() const { return Kind; } + llvm::omp::DefaultKind getDefaultKind() const { return Kind; } /// Returns location of clause kind. SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits