[OPENMP50]Add initial support for OpenMP 5.0 iterator.
Added basic parsing/semantic analysis/(de)serialization support for
iterator expression introduced in OpenMP 5.0.
diff --git a/clang/lib/Serialization/ASTCommon.cpp b/clang/lib/Serialization/ASTCommon.cpp
index 158a12f..566bda2 100644
--- a/clang/lib/Serialization/ASTCommon.cpp
+++ b/clang/lib/Serialization/ASTCommon.cpp
@@ -246,6 +246,9 @@
case BuiltinType::OMPArrayShaping:
ID = PREDEF_TYPE_OMP_ARRAY_SHAPING;
break;
+ case BuiltinType::OMPIterator:
+ ID = PREDEF_TYPE_OMP_ITERATOR;
+ break;
}
return TypeIdx(ID);
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index bea9bdd..74bb1c7 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -6960,6 +6960,9 @@
case PREDEF_TYPE_OMP_ARRAY_SHAPING:
T = Context.OMPArraySectionTy;
break;
+ case PREDEF_TYPE_OMP_ITERATOR:
+ T = Context.OMPIteratorTy;
+ break;
#define SVE_TYPE(Name, Id, SingletonId) \
case PREDEF_TYPE_##Id##_ID: \
T = Context.SingletonId; \
@@ -12307,6 +12310,7 @@
void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
C->setLParenLoc(Record.readSourceLocation());
+ C->setModifier(Record.readSubExpr());
C->setDependencyKind(
static_cast<OpenMPDependClauseKind>(Record.readInt()));
C->setDependencyLoc(Record.readSourceLocation());
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index bc8c231..2c91565 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -927,6 +927,26 @@
E->setRParenLoc(readSourceLocation());
}
+void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
+ VisitExpr(E);
+ unsigned NumIters = Record.readInt();
+ E->setIteratorKwLoc(readSourceLocation());
+ E->setLParenLoc(readSourceLocation());
+ E->setRParenLoc(readSourceLocation());
+ for (unsigned I = 0; I < NumIters; ++I) {
+ E->setIteratorDeclaration(I, Record.readDeclRef());
+ E->setAssignmentLoc(I, readSourceLocation());
+ Expr *Begin = Record.readSubExpr();
+ Expr *End = Record.readSubExpr();
+ Expr *Step = Record.readSubExpr();
+ SourceLocation ColonLoc = readSourceLocation();
+ SourceLocation SecColonLoc;
+ if (Step)
+ SecColonLoc = readSourceLocation();
+ E->setIteratorRange(I, Begin, ColonLoc, End, SecColonLoc, Step);
+ }
+}
+
void ASTStmtReader::VisitCallExpr(CallExpr *E) {
VisitExpr(E);
unsigned NumArgs = Record.readInt();
@@ -2887,6 +2907,11 @@
Context, Record[ASTStmtReader::NumExprFields]);
break;
+ case EXPR_OMP_ITERATOR:
+ S = OMPIteratorExpr::CreateEmpty(Context,
+ Record[ASTStmtReader::NumExprFields]);
+ break;
+
case EXPR_CALL:
S = CallExpr::CreateEmpty(
Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index f7c58ed..27f44a7 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -6379,6 +6379,7 @@
Record.push_back(C->varlist_size());
Record.push_back(C->getNumLoops());
Record.AddSourceLocation(C->getLParenLoc());
+ Record.AddStmt(C->getModifier());
Record.push_back(C->getDependencyKind());
Record.AddSourceLocation(C->getDependencyLoc());
Record.AddSourceLocation(C->getColonLoc());
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 8408232..ee8bb3e 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -787,6 +787,26 @@
Code = serialization::EXPR_OMP_ARRAY_SHAPING;
}
+void ASTStmtWriter::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
+ VisitExpr(E);
+ Record.push_back(E->numOfIterators());
+ Record.AddSourceLocation(E->getIteratorKwLoc());
+ Record.AddSourceLocation(E->getLParenLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
+ for (unsigned I = 0, End = E->numOfIterators(); I < End; ++I) {
+ Record.AddDeclRef(E->getIteratorDecl(I));
+ Record.AddSourceLocation(E->getAssignLoc(I));
+ OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
+ Record.AddStmt(Range.Begin);
+ Record.AddStmt(Range.End);
+ Record.AddStmt(Range.Step);
+ Record.AddSourceLocation(E->getColonLoc(I));
+ if (Range.Step)
+ Record.AddSourceLocation(E->getSecondColonLoc(I));
+ }
+ Code = serialization::EXPR_OMP_ITERATOR;
+}
+
void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumArgs());