r258817 - [OpenMP] Parsing + sema for defaultmap clause.
Arpith Chacko Jacob via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 26 08:37:24 PST 2016
Author: arpith
Date: Tue Jan 26 10:37:23 2016
New Revision: 258817
URL: http://llvm.org/viewvc/llvm-project?rev=258817&view=rev
Log:
[OpenMP] Parsing + sema for defaultmap clause.
Summary:
This patch adds parsing + sema for the defaultmap clause associated with the target directive (among others).
Reviewers: ABataev
Differential Revision: http://reviews.llvm.org/D16527
Added:
cfe/trunk/test/OpenMP/target_defaultmap_messages.cpp
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/target_ast_print.cpp
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Jan 26 10:37:23 2016
@@ -3338,6 +3338,109 @@ public:
return child_range(&ChunkSizes[CHUNK_SIZE], &ChunkSizes[CHUNK_SIZE] + 1);
}
};
+
+/// \brief This represents 'defaultmap' clause in the '#pragma omp ...' directive.
+///
+/// \code
+/// #pragma omp target defaultmap(tofrom: scalar)
+/// \endcode
+/// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
+/// 'scalar' with modifier 'tofrom'.
+///
+class OMPDefaultmapClause : public OMPClause {
+ friend class OMPClauseReader;
+ /// \brief Location of '('.
+ SourceLocation LParenLoc;
+ /// \brief Modifiers for 'defaultmap' clause.
+ OpenMPDefaultmapClauseModifier Modifier;
+ /// \brief Locations of modifiers.
+ SourceLocation ModifierLoc;
+ /// \brief A kind of the 'defaultmap' clause.
+ OpenMPDefaultmapClauseKind Kind;
+ /// \brief Start location of the defaultmap kind in source code.
+ SourceLocation KindLoc;
+
+ /// \brief Set defaultmap kind.
+ ///
+ /// \param K Defaultmap kind.
+ ///
+ void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
+ /// \brief Set the defaultmap modifier.
+ ///
+ /// \param M Defaultmap modifier.
+ ///
+ void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
+ Modifier = M;
+ }
+ /// \brief Set location of the defaultmap modifier.
+ ///
+ void setDefaultmapModifierLoc(SourceLocation Loc) {
+ ModifierLoc = Loc;
+ }
+ /// \brief Sets the location of '('.
+ ///
+ /// \param Loc Location of '('.
+ ///
+ void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+ /// \brief Set defaultmap kind start location.
+ ///
+ /// \param KLoc Defaultmap kind location.
+ ///
+ void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
+
+public:
+ /// \brief Build 'defaultmap' clause with defaultmap kind \a Kind
+ ///
+ /// \param StartLoc Starting location of the clause.
+ /// \param LParenLoc Location of '('.
+ /// \param KLoc Starting location of the argument.
+ /// \param EndLoc Ending location of the clause.
+ /// \param Kind Defaultmap kind.
+ /// \param M The modifier applied to 'defaultmap' clause.
+ /// \param MLoc Location of the modifier
+ ///
+ OMPDefaultmapClause(SourceLocation StartLoc, SourceLocation LParenLoc,
+ SourceLocation MLoc, SourceLocation KLoc,
+ SourceLocation EndLoc, OpenMPDefaultmapClauseKind Kind,
+ OpenMPDefaultmapClauseModifier M)
+ : OMPClause(OMPC_defaultmap, StartLoc, EndLoc), LParenLoc(LParenLoc),
+ Modifier(M), ModifierLoc(MLoc), Kind(Kind), KindLoc(KLoc) {}
+
+ /// \brief Build an empty clause.
+ ///
+ explicit OMPDefaultmapClause()
+ : OMPClause(OMPC_defaultmap, SourceLocation(), SourceLocation()),
+ Modifier(OMPC_DEFAULTMAP_MODIFIER_unknown),
+ Kind(OMPC_DEFAULTMAP_unknown) {}
+
+ /// \brief Get kind of the clause.
+ ///
+ OpenMPDefaultmapClauseKind getDefaultmapKind() const { return Kind; }
+ /// \brief Get the modifier of the clause.
+ ///
+ OpenMPDefaultmapClauseModifier getDefaultmapModifier() const {
+ return Modifier;
+ }
+ /// \brief Get location of '('.
+ ///
+ SourceLocation getLParenLoc() { return LParenLoc; }
+ /// \brief Get kind location.
+ ///
+ SourceLocation getDefaultmapKindLoc() { return KindLoc; }
+ /// \brief Get the modifier location.
+ ///
+ SourceLocation getDefaultmapModifierLoc() const {
+ return ModifierLoc;
+ }
+
+ static bool classof(const OMPClause *T) {
+ return T->getClauseKind() == OMPC_defaultmap;
+ }
+
+ child_range children() {
+ return child_range(child_iterator(), child_iterator());
+ }
+};
} // end namespace clang
#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Jan 26 10:37:23 2016
@@ -2800,6 +2800,12 @@ bool RecursiveASTVisitor<Derived>::Visit
return true;
}
+template <typename Derived>
+bool
+RecursiveASTVisitor<Derived>::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
+ return true;
+}
+
// FIXME: look at the following tricky-seeming exprs to see if we
// need to recurse on anything. These are ones that have methods
// returning decls or qualtypes or nestednamespecifier -- though I'm
Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Tue Jan 26 10:37:23 2016
@@ -111,6 +111,12 @@
#ifndef OPENMP_DIST_SCHEDULE_KIND
#define OPENMP_DIST_SCHEDULE_KIND(Name)
#endif
+#ifndef OPENMP_DEFAULTMAP_KIND
+#define OPENMP_DEFAULTMAP_KIND(Name)
+#endif
+#ifndef OPENMP_DEFAULTMAP_MODIFIER
+#define OPENMP_DEFAULTMAP_MODIFIER(Name)
+#endif
// OpenMP directives.
OPENMP_DIRECTIVE(threadprivate)
@@ -187,6 +193,7 @@ OPENMP_CLAUSE(nogroup, OMPNogroupClause)
OPENMP_CLAUSE(num_tasks, OMPNumTasksClause)
OPENMP_CLAUSE(hint, OMPHintClause)
OPENMP_CLAUSE(dist_schedule, OMPDistScheduleClause)
+OPENMP_CLAUSE(defaultmap, OMPDefaultmapClause)
// Clauses allowed for OpenMP directive 'parallel'.
OPENMP_PARALLEL_CLAUSE(if)
@@ -271,6 +278,12 @@ OPENMP_SCHEDULE_MODIFIER(monotonic)
OPENMP_SCHEDULE_MODIFIER(nonmonotonic)
OPENMP_SCHEDULE_MODIFIER(simd)
+// Static attributes for 'defaultmap' clause.
+OPENMP_DEFAULTMAP_KIND(scalar)
+
+// Modifiers for 'defaultmap' clause.
+OPENMP_DEFAULTMAP_MODIFIER(tofrom)
+
// Static attributes for 'depend' clause.
OPENMP_DEPEND_KIND(in)
OPENMP_DEPEND_KIND(out)
@@ -357,6 +370,7 @@ OPENMP_TARGET_CLAUSE(map)
OPENMP_TARGET_CLAUSE(private)
OPENMP_TARGET_CLAUSE(nowait)
OPENMP_TARGET_CLAUSE(depend)
+OPENMP_TARGET_CLAUSE(defaultmap)
// Clauses allowed for OpenMP directive 'target data'.
// TODO More clauses for 'target data' directive.
@@ -485,3 +499,5 @@ OPENMP_DIST_SCHEDULE_KIND(static)
#undef OPENMP_MAP_KIND
#undef OPENMP_DISTRIBUTE_CLAUSE
#undef OPENMP_DIST_SCHEDULE_KIND
+#undef OPENMP_DEFAULTMAP_KIND
+#undef OPENMP_DEFAULTMAP_MODIFIER
Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Tue Jan 26 10:37:23 2016
@@ -102,6 +102,23 @@ enum OpenMPDistScheduleClauseKind {
OMPC_DIST_SCHEDULE_unknown
};
+/// \brief OpenMP attributes for 'defaultmap' clause.
+enum OpenMPDefaultmapClauseKind {
+#define OPENMP_DEFAULTMAP_KIND(Name) \
+ OMPC_DEFAULTMAP_##Name,
+#include "clang/Basic/OpenMPKinds.def"
+ OMPC_DEFAULTMAP_unknown
+};
+
+/// \brief OpenMP modifiers for 'defaultmap' clause.
+enum OpenMPDefaultmapClauseModifier {
+ OMPC_DEFAULTMAP_MODIFIER_unknown = OMPC_DEFAULTMAP_unknown,
+#define OPENMP_DEFAULTMAP_MODIFIER(Name) \
+ OMPC_DEFAULTMAP_MODIFIER_##Name,
+#include "clang/Basic/OpenMPKinds.def"
+ OMPC_DEFAULTMAP_MODIFIER_last
+};
+
OpenMPDirectiveKind getOpenMPDirectiveKind(llvm::StringRef Str);
const char *getOpenMPDirectiveName(OpenMPDirectiveKind Kind);
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Jan 26 10:37:23 2016
@@ -8213,6 +8213,11 @@ public:
OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc,
SourceLocation CommaLoc, SourceLocation EndLoc);
+ /// \brief Called on well-formed 'defaultmap' clause.
+ OMPClause *ActOnOpenMPDefaultmapClause(
+ OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind,
+ SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc,
+ SourceLocation KindLoc, SourceLocation EndLoc);
/// \brief The kind of conversion being performed.
enum CheckedConversionKind {
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Tue Jan 26 10:37:23 2016
@@ -919,6 +919,16 @@ void OMPClausePrinter::VisitOMPDistSched
}
OS << ")";
}
+
+void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
+ OS << "defaultmap(";
+ OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
+ Node->getDefaultmapModifier());
+ OS << ": ";
+ OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
+ Node->getDefaultmapKind());
+ OS << ")";
+}
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Tue Jan 26 10:37:23 2016
@@ -631,6 +631,8 @@ void OMPClauseProfiler::VisitOMPDistSche
}
}
+void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
+
void StmtProfiler::VisitExpr(const Expr *S) {
VisitStmt(S);
}
Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Tue Jan 26 10:37:23 2016
@@ -114,6 +114,14 @@ unsigned clang::getOpenMPSimpleClauseTyp
#define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
#include "clang/Basic/OpenMPKinds.def"
.Default(OMPC_DIST_SCHEDULE_unknown);
+ case OMPC_defaultmap:
+ return llvm::StringSwitch<unsigned>(Str)
+#define OPENMP_DEFAULTMAP_KIND(Name) \
+ .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
+#define OPENMP_DEFAULTMAP_MODIFIER(Name) \
+ .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
+#include "clang/Basic/OpenMPKinds.def"
+ .Default(OMPC_DEFAULTMAP_unknown);
case OMPC_unknown:
case OMPC_threadprivate:
case OMPC_if:
@@ -234,6 +242,20 @@ const char *clang::getOpenMPSimpleClause
#include "clang/Basic/OpenMPKinds.def"
}
llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
+ case OMPC_defaultmap:
+ switch (Type) {
+ case OMPC_DEFAULTMAP_unknown:
+ case OMPC_DEFAULTMAP_MODIFIER_last:
+ return "unknown";
+#define OPENMP_DEFAULTMAP_KIND(Name) \
+ case OMPC_DEFAULTMAP_##Name: \
+ return #Name;
+#define OPENMP_DEFAULTMAP_MODIFIER(Name) \
+ case OMPC_DEFAULTMAP_MODIFIER_##Name: \
+ return #Name;
+#include "clang/Basic/OpenMPKinds.def"
+ }
+ llvm_unreachable("Invalid OpenMP 'schedule' clause type");
case OMPC_unknown:
case OMPC_threadprivate:
case OMPC_if:
Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Tue Jan 26 10:37:23 2016
@@ -2564,6 +2564,7 @@ static void EmitOMPAtomicExpr(CodeGenFun
case OMPC_num_tasks:
case OMPC_hint:
case OMPC_dist_schedule:
+ case OMPC_defaultmap:
llvm_unreachable("Clause is not allowed in 'omp atomic'.");
}
}
Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Tue Jan 26 10:37:23 2016
@@ -512,8 +512,11 @@ OMPClause *Parser::ParseOpenMPClause(Ope
break;
case OMPC_schedule:
case OMPC_dist_schedule:
+ case OMPC_defaultmap:
// OpenMP [2.7.1, Restrictions, p. 3]
// Only one schedule clause can appear on a loop directive.
+ // OpenMP [2.10.4, Restrictions, p. 106]
+ // At most one defaultmap clause can appear on the directive.
if (!FirstClause) {
Diag(Tok, diag::err_omp_more_one_clause)
<< getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind) << 0;
@@ -703,6 +706,9 @@ OMPClause *Parser::ParseOpenMPClause(Ope
/// if-clause:
/// 'if' '(' [ directive-name-modifier ':' ] expression ')'
///
+/// defaultmap:
+/// 'defaultmap' '(' modifier ':' kind ')'
+///
OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPClauseKind Kind) {
SourceLocation Loc = ConsumeToken();
SourceLocation DelimLoc;
@@ -771,6 +777,26 @@ OMPClause *Parser::ParseOpenMPSingleExpr
ConsumeAnyToken();
if (Arg.back() == OMPC_DIST_SCHEDULE_static && Tok.is(tok::comma))
DelimLoc = ConsumeAnyToken();
+ } else if (Kind == OMPC_defaultmap) {
+ // Get a defaultmap modifier
+ Arg.push_back(getOpenMPSimpleClauseType(
+ Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok)));
+ KLoc.push_back(Tok.getLocation());
+ if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
+ Tok.isNot(tok::annot_pragma_openmp_end))
+ ConsumeAnyToken();
+ // Parse ':'
+ if (Tok.is(tok::colon))
+ ConsumeAnyToken();
+ else if (Arg.back() != OMPC_DEFAULTMAP_MODIFIER_unknown)
+ Diag(Tok, diag::warn_pragma_expected_colon) << "defaultmap modifier";
+ // Get a defaultmap kind
+ Arg.push_back(getOpenMPSimpleClauseType(
+ Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok)));
+ KLoc.push_back(Tok.getLocation());
+ if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
+ Tok.isNot(tok::annot_pragma_openmp_end))
+ ConsumeAnyToken();
} else {
assert(Kind == OMPC_if);
KLoc.push_back(Tok.getLocation());
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 26 10:37:23 2016
@@ -5921,6 +5921,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprCl
case OMPC_map:
case OMPC_nogroup:
case OMPC_dist_schedule:
+ case OMPC_defaultmap:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -6205,6 +6206,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause
case OMPC_num_tasks:
case OMPC_hint:
case OMPC_dist_schedule:
+ case OMPC_defaultmap:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -6308,6 +6310,14 @@ OMPClause *Sema::ActOnOpenMPSingleExprWi
static_cast<OpenMPDistScheduleClauseKind>(Argument.back()), Expr,
StartLoc, LParenLoc, ArgumentLoc.back(), DelimLoc, EndLoc);
break;
+ case OMPC_defaultmap:
+ enum { Modifier, DefaultmapKind };
+ Res = ActOnOpenMPDefaultmapClause(
+ static_cast<OpenMPDefaultmapClauseModifier>(Argument[Modifier]),
+ static_cast<OpenMPDefaultmapClauseKind>(Argument[DefaultmapKind]),
+ StartLoc, LParenLoc, ArgumentLoc[Modifier],
+ ArgumentLoc[DefaultmapKind], EndLoc);
+ break;
case OMPC_final:
case OMPC_num_threads:
case OMPC_safelen:
@@ -6532,6 +6542,7 @@ OMPClause *Sema::ActOnOpenMPClause(OpenM
case OMPC_num_tasks:
case OMPC_hint:
case OMPC_dist_schedule:
+ case OMPC_defaultmap:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -6676,6 +6687,7 @@ OMPClause *Sema::ActOnOpenMPVarListClaus
case OMPC_num_tasks:
case OMPC_hint:
case OMPC_dist_schedule:
+ case OMPC_defaultmap:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -9222,3 +9234,32 @@ OMPClause *Sema::ActOnOpenMPDistSchedule
OMPDistScheduleClause(StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc,
Kind, ValExpr, HelperValExpr);
}
+
+OMPClause *Sema::ActOnOpenMPDefaultmapClause(
+ OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind,
+ SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc,
+ SourceLocation KindLoc, SourceLocation EndLoc) {
+ // OpenMP 4.5 only supports 'defaultmap(tofrom: scalar)'
+ if (M != OMPC_DEFAULTMAP_MODIFIER_tofrom ||
+ Kind != OMPC_DEFAULTMAP_scalar) {
+ std::string Value;
+ SourceLocation Loc;
+ Value += "'";
+ if (M != OMPC_DEFAULTMAP_MODIFIER_tofrom) {
+ Value += getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
+ OMPC_DEFAULTMAP_MODIFIER_tofrom);
+ Loc = MLoc;
+ } else {
+ Value += getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
+ OMPC_DEFAULTMAP_scalar);
+ Loc = KindLoc;
+ }
+ Value += "'";
+ Diag(Loc, diag::err_omp_unexpected_clause_value)
+ << Value << getOpenMPClauseName(OMPC_defaultmap);
+ return nullptr;
+ }
+
+ return new (Context)
+ OMPDefaultmapClause(StartLoc, LParenLoc, MLoc, KindLoc, EndLoc, Kind, M);
+}
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Jan 26 10:37:23 2016
@@ -7936,6 +7936,12 @@ OMPClause *TreeTransform<Derived>::Trans
C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getLocEnd());
}
+template <typename Derived>
+OMPClause *
+TreeTransform<Derived>::TransformOMPDefaultmapClause(OMPDefaultmapClause *C) {
+ return C;
+}
+
//===----------------------------------------------------------------------===//
// Expression transformation
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Tue Jan 26 10:37:23 2016
@@ -1881,6 +1881,9 @@ OMPClause *OMPClauseReader::readClause()
case OMPC_dist_schedule:
C = new (Context) OMPDistScheduleClause();
break;
+ case OMPC_defaultmap:
+ C = new (Context) OMPDefaultmapClause();
+ break;
}
Visit(C);
C->setLocStart(Reader->ReadSourceLocation(Record, Idx));
@@ -2253,6 +2256,16 @@ void OMPClauseReader::VisitOMPDistSchedu
C->setCommaLoc(Reader->ReadSourceLocation(Record, Idx));
}
+void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
+ C->setDefaultmapKind(
+ static_cast<OpenMPDefaultmapClauseKind>(Record[Idx++]));
+ C->setDefaultmapModifier(
+ static_cast<OpenMPDefaultmapClauseModifier>(Record[Idx++]));
+ C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setDefaultmapModifierLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setDefaultmapKindLoc(Reader->ReadSourceLocation(Record, Idx));
+}
+
//===----------------------------------------------------------------------===//
// OpenMP Directives.
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Tue Jan 26 10:37:23 2016
@@ -2046,6 +2046,14 @@ void OMPClauseWriter::VisitOMPDistSchedu
Writer->Writer.AddSourceLocation(C->getCommaLoc(), Record);
}
+void OMPClauseWriter::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
+ Record.push_back(C->getDefaultmapKind());
+ Record.push_back(C->getDefaultmapModifier());
+ Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Writer->Writer.AddSourceLocation(C->getDefaultmapModifierLoc(), Record);
+ Writer->Writer.AddSourceLocation(C->getDefaultmapKindLoc(), Record);
+}
+
//===----------------------------------------------------------------------===//
// OpenMP Directives.
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/test/OpenMP/target_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_ast_print.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/target_ast_print.cpp Tue Jan 26 10:37:23 2016
@@ -29,6 +29,8 @@ T tmain(T argc, T *argv) {
foo();
#pragma omp target depend(in : argc, argv[i:argc], a[:])
foo();
+#pragma omp target defaultmap(tofrom: scalar)
+ foo();
return 0;
}
@@ -52,6 +54,8 @@ T tmain(T argc, T *argv) {
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
+// CHECK-NEXT: foo()
// CHECK: template <typename T = char, int C = 1> char tmain(char argc, char *argv) {
// CHECK-NEXT: char i, j, a[20]
// CHECK-NEXT: #pragma omp target
@@ -72,6 +76,8 @@ T tmain(T argc, T *argv) {
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
+// CHECK-NEXT: foo()
// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
// CHECK-NEXT: T i, j, a[20]
// CHECK-NEXT: #pragma omp target
@@ -92,6 +98,8 @@ T tmain(T argc, T *argv) {
// CHECK-NEXT: foo()
// CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
+// CHECK-NEXT: foo()
// CHECK-LABEL: int main(int argc, char **argv) {
int main (int argc, char **argv) {
@@ -141,6 +149,11 @@ int main (int argc, char **argv) {
foo();
// CHECK-NEXT: foo();
+#pragma omp target defaultmap(tofrom: scalar)
+// CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
+ foo();
+// CHECK-NEXT: foo();
+
return tmain<int, 5>(argc, &argc) + tmain<char, 1>(argv[0][0], argv[0]);
}
Added: cfe/trunk/test/OpenMP/target_defaultmap_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_defaultmap_messages.cpp?rev=258817&view=auto
==============================================================================
--- cfe/trunk/test/OpenMP/target_defaultmap_messages.cpp (added)
+++ cfe/trunk/test/OpenMP/target_defaultmap_messages.cpp Tue Jan 26 10:37:23 2016
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -verify -fopenmp %s
+
+void foo() {
+}
+
+template <class T, typename S, int N, int ST>
+T tmain(T argc, S **argv) {
+ #pragma omp target defaultmap // expected-error {{expected '(' after 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}}
+ foo();
+ #pragma omp target defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target defaultmap (tofrom, scalar // expected-error {{expected ')'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+ foo();
+
+ return argc;
+}
+
+int main(int argc, char **argv) {
+ #pragma omp target defaultmap // expected-error {{expected '(' after 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+ foo();
+ #pragma omp target defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}}
+ foo();
+ #pragma omp target defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target defaultmap (tofrom, scalar // expected-error {{expected ')'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+ foo();
+
+ return tmain<int, char, 1, 0>(argc, argv);
+}
+
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=258817&r1=258816&r2=258817&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jan 26 10:37:23 2016
@@ -2229,6 +2229,8 @@ void OMPClauseEnqueue::VisitOMPDistSched
Visitor->AddStmt(C->getChunkSize());
Visitor->AddStmt(C->getHelperChunkSize());
}
+void OMPClauseEnqueue::VisitOMPDefaultmapClause(const OMPDefaultmapClause *C) {
+}
}
void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
More information about the cfe-commits
mailing list