[OpenMP][NFCI] Use the libFrontend DefaultKind in Clang

This swaps out the OpenMPDefaultClauseKind enum with a
llvm::omp::DefaultKind enum which is stored in OMPConstants.h.

This should not change any functionality.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D74513
This commit is contained in:
Atmn Patel 2020-02-14 21:45:49 -06:00 committed by Johannes Doerfert
parent fd5665af2c
commit 577c9b02ab
13 changed files with 58 additions and 57 deletions

View File

@ -867,7 +867,7 @@ class OMPDefaultClause : public OMPClause {
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;
@ -875,7 +875,7 @@ class OMPDefaultClause : public OMPClause {
/// 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.
///
@ -890,7 +890,7 @@ public:
/// \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),
@ -907,7 +907,7 @@ public:
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; }

View File

@ -7049,7 +7049,7 @@ extern const internal::VariadicDynCastAllOfMatcher<OMPClause, OMPDefaultClause>
///
/// ``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.
@ -7064,7 +7064,7 @@ AST_MATCHER(OMPDefaultClause, isNoneKind) {
///
/// ``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

View File

@ -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
@ -351,10 +348,6 @@ OPENMP_SINGLE_CLAUSE(allocate)
// 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)
@ -1103,7 +1096,6 @@ OPENMP_FLUSH_CLAUSE(release)
#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

View File

@ -34,14 +34,6 @@ enum OpenMPClauseKind {
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) \

View File

@ -10269,7 +10269,7 @@ public:
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,

View File

@ -1244,7 +1244,8 @@ void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) {
void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
OS << "default("
<< getOpenMPSimpleClauseTypeName(OMPC_default, Node->getDefaultKind())
<< getOpenMPSimpleClauseTypeName(OMPC_default,
unsigned(Node->getDefaultKind()))
<< ")";
}

View File

@ -61,10 +61,10 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
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, unsigned(Enum))
#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)
@ -203,13 +203,11 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
unsigned Type) {
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"
switch (llvm::omp::DefaultKind(Type)) {
#define OMP_DEFAULT_KIND(Enum, Name) \
case Enum: \
return Name;
#include "llvm/Frontend/OpenMP/OMPKinds.def"
}
llvm_unreachable("Invalid OpenMP 'default' clause type");
case OMPC_proc_bind:

View File

@ -12009,8 +12009,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
OMPClause *Res = nullptr;
switch (Kind) {
case OMPC_default:
Res =
ActOnOpenMPDefaultClause(static_cast<OpenMPDefaultClauseKind>(Argument),
Res = ActOnOpenMPDefaultClause(static_cast<DefaultKind>(Argument),
ArgumentLoc, StartLoc, LParenLoc, EndLoc);
break;
case OMPC_proc_bind:
@ -12114,31 +12113,23 @@ getListOfPossibleValues(OpenMPClauseKind K, unsigned First, unsigned Last,
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)
/*Last=*/unsigned(OMP_DEFAULT_unknown))
<< 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);
}

View File

@ -1602,8 +1602,7 @@ public:
///
/// 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) {

View File

@ -11887,8 +11887,7 @@ void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) {
}
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());
}

View File

@ -6097,7 +6097,7 @@ void OMPClauseWriter::VisitOMPCollapseClause(OMPCollapseClause *C) {
}
void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) {
Record.push_back(C->getDefaultKind());
Record.push_back(unsigned(C->getDefaultKind()));
Record.AddSourceLocation(C->getLParenLoc());
Record.AddSourceLocation(C->getDefaultKindKwLoc());
}

View File

@ -49,6 +49,16 @@ enum class RuntimeFunction {
#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,

View File

@ -344,6 +344,25 @@ __OMP_CANCEL_KIND(taskgroup, 4)
///}
/// 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
///
///{