r262696 - [OPENMP] Simplify handling of clauses with postupdates, NFC.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 3 23:21:17 PST 2016
Author: abataev
Date: Fri Mar 4 01:21:16 2016
New Revision: 262696
URL: http://llvm.org/viewvc/llvm-project?rev=262696&view=rev
Log:
[OPENMP] Simplify handling of clauses with postupdates, NFC.
Clauses with post-update expressions always have pre-init statement. So
OMPClauseWithPreInit now is the base for OMPClauseWithPostUpdate.
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.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=262696&r1=262695&r2=262696&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Fri Mar 4 01:21:16 2016
@@ -80,7 +80,7 @@ protected:
/// Set pre-initialization statement for the clause.
void setPreInitStmt(Stmt *S) { PreInit = S; }
OMPClauseWithPreInit(const OMPClause *This) : PreInit(nullptr) {
- assert(get(This) && "get is not tuned.");
+ assert(get(This) && "get is not tuned for pre-init.");
}
public:
@@ -94,15 +94,16 @@ public:
/// Class that handles post-update expression for some clauses, like
/// 'lastprivate', 'reduction' etc.
-class OMPClauseWithPostUpdate {
+class OMPClauseWithPostUpdate : public OMPClauseWithPreInit {
friend class OMPClauseReader;
/// Post-update expression for the clause.
Expr *PostUpdate;
protected:
/// Set pre-initialization statement for the clause.
void setPostUpdateExpr(Expr *S) { PostUpdate = S; }
- OMPClauseWithPostUpdate(const OMPClause *This) : PostUpdate(nullptr) {
- assert(get(This) && "get is not tuned.");
+ OMPClauseWithPostUpdate(const OMPClause *This)
+ : OMPClauseWithPreInit(This), PostUpdate(nullptr) {
+ assert(get(This) && "get is not tuned for post-update.");
}
public:
@@ -1404,7 +1405,6 @@ public:
/// with the variables 'a' and 'b'.
class OMPLastprivateClause final
: public OMPVarListClause<OMPLastprivateClause>,
- public OMPClauseWithPreInit,
public OMPClauseWithPostUpdate,
private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
// There are 4 additional tail-allocated arrays at the end of the class:
@@ -1439,7 +1439,7 @@ class OMPLastprivateClause final
SourceLocation EndLoc, unsigned N)
: OMPVarListClause<OMPLastprivateClause>(OMPC_lastprivate, StartLoc,
LParenLoc, EndLoc, N),
- OMPClauseWithPreInit(this), OMPClauseWithPostUpdate(this) {}
+ OMPClauseWithPostUpdate(this) {}
/// \brief Build an empty clause.
///
@@ -1449,7 +1449,7 @@ class OMPLastprivateClause final
: OMPVarListClause<OMPLastprivateClause>(
OMPC_lastprivate, SourceLocation(), SourceLocation(),
SourceLocation(), N),
- OMPClauseWithPreInit(this), OMPClauseWithPostUpdate(this) {}
+ OMPClauseWithPostUpdate(this) {}
/// \brief Get the list of helper expressions for initialization of private
/// copies for lastprivate variables.
@@ -1665,7 +1665,6 @@ public:
///
class OMPReductionClause final
: public OMPVarListClause<OMPReductionClause>,
- public OMPClauseWithPreInit,
public OMPClauseWithPostUpdate,
private llvm::TrailingObjects<OMPReductionClause, Expr *> {
friend TrailingObjects;
@@ -1694,8 +1693,8 @@ class OMPReductionClause final
const DeclarationNameInfo &NameInfo)
: OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
LParenLoc, EndLoc, N),
- OMPClauseWithPreInit(this), OMPClauseWithPostUpdate(this),
- ColonLoc(ColonLoc), QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
+ OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
+ QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
/// \brief Build an empty clause.
///
@@ -1705,8 +1704,7 @@ class OMPReductionClause final
: OMPVarListClause<OMPReductionClause>(OMPC_reduction, SourceLocation(),
SourceLocation(), SourceLocation(),
N),
- OMPClauseWithPreInit(this), OMPClauseWithPostUpdate(this), ColonLoc(),
- QualifierLoc(), NameInfo() {}
+ OMPClauseWithPostUpdate(this), ColonLoc(), QualifierLoc(), NameInfo() {}
/// \brief Sets location of ':' symbol in clause.
void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=262696&r1=262695&r2=262696&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Mar 4 01:21:16 2016
@@ -2533,6 +2533,7 @@ bool RecursiveASTVisitor<Derived>::Visit
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPClauseWithPostUpdate(
OMPClauseWithPostUpdate *Node) {
+ TRY_TO(VisitOMPClauseWithPreInit(Node));
TRY_TO(TraverseStmt(Node->getPostUpdateExpr()));
return true;
}
@@ -2691,7 +2692,6 @@ template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPLastprivateClause(
OMPLastprivateClause *C) {
TRY_TO(VisitOMPClauseList(C));
- TRY_TO(VisitOMPClauseWithPreInit(C));
TRY_TO(VisitOMPClauseWithPostUpdate(C));
for (auto *E : C->private_copies()) {
TRY_TO(TraverseStmt(E));
@@ -2778,7 +2778,6 @@ RecursiveASTVisitor<Derived>::VisitOMPRe
TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
TRY_TO(VisitOMPClauseList(C));
- TRY_TO(VisitOMPClauseWithPreInit(C));
TRY_TO(VisitOMPClauseWithPostUpdate(C));
for (auto *E : C->privates()) {
TRY_TO(TraverseStmt(E));
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=262696&r1=262695&r2=262696&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Mar 4 01:21:16 2016
@@ -280,6 +280,7 @@ void OMPClauseProfiler::VistOMPClauseWit
void OMPClauseProfiler::VistOMPClauseWithPostUpdate(
const OMPClauseWithPostUpdate *C) {
+ VistOMPClauseWithPreInit(C);
if (auto *E = C->getPostUpdateExpr())
Profiler->VisitStmt(E);
}
@@ -378,7 +379,6 @@ OMPClauseProfiler::VisitOMPFirstprivateC
void
OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
VisitOMPClauseList(C);
- VistOMPClauseWithPreInit(C);
VistOMPClauseWithPostUpdate(C);
for (auto *E : C->source_exprs()) {
Profiler->VisitStmt(E);
@@ -399,7 +399,6 @@ void OMPClauseProfiler::VisitOMPReductio
C->getQualifierLoc().getNestedNameSpecifier());
Profiler->VisitName(C->getNameInfo().getName());
VisitOMPClauseList(C);
- VistOMPClauseWithPreInit(C);
VistOMPClauseWithPostUpdate(C);
for (auto *E : C->privates()) {
Profiler->VisitStmt(E);
Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=262696&r1=262695&r2=262696&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Fri Mar 4 01:21:16 2016
@@ -1898,6 +1898,7 @@ void OMPClauseReader::VisitOMPClauseWith
}
void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
+ VisitOMPClauseWithPreInit(C);
C->setPostUpdateExpr(Reader->Reader.ReadSubExpr());
}
@@ -2025,7 +2026,6 @@ void OMPClauseReader::VisitOMPFirstpriva
}
void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
- VisitOMPClauseWithPreInit(C);
VisitOMPClauseWithPostUpdate(C);
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
unsigned NumVars = C->varlist_size();
@@ -2063,7 +2063,6 @@ void OMPClauseReader::VisitOMPSharedClau
}
void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
- VisitOMPClauseWithPreInit(C);
VisitOMPClauseWithPostUpdate(C);
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=262696&r1=262695&r2=262696&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Fri Mar 4 01:21:16 2016
@@ -1771,6 +1771,7 @@ void OMPClauseWriter::VisitOMPClauseWith
}
void OMPClauseWriter::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
+ VisitOMPClauseWithPreInit(C);
Writer->Writer.AddStmt(C->getPostUpdateExpr());
}
@@ -1887,7 +1888,6 @@ void OMPClauseWriter::VisitOMPFirstpriva
void OMPClauseWriter::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
Record.push_back(C->varlist_size());
- VisitOMPClauseWithPreInit(C);
VisitOMPClauseWithPostUpdate(C);
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
for (auto *VE : C->varlists())
@@ -1911,7 +1911,6 @@ void OMPClauseWriter::VisitOMPSharedClau
void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *C) {
Record.push_back(C->varlist_size());
- VisitOMPClauseWithPreInit(C);
VisitOMPClauseWithPostUpdate(C);
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=262696&r1=262695&r2=262696&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Mar 4 01:21:16 2016
@@ -2041,6 +2041,7 @@ void OMPClauseEnqueue::VisitOMPClauseWit
void OMPClauseEnqueue::VisitOMPClauseWithPostUpdate(
const OMPClauseWithPostUpdate *C) {
+ VisitOMPClauseWithPreInit(C);
Visitor->AddStmt(C->getPostUpdateExpr());
}
@@ -2158,7 +2159,6 @@ void OMPClauseEnqueue::VisitOMPFirstpriv
void OMPClauseEnqueue::VisitOMPLastprivateClause(
const OMPLastprivateClause *C) {
VisitOMPClauseList(C);
- VisitOMPClauseWithPreInit(C);
VisitOMPClauseWithPostUpdate(C);
for (auto *E : C->private_copies()) {
Visitor->AddStmt(E);
@@ -2178,7 +2178,6 @@ void OMPClauseEnqueue::VisitOMPSharedCla
}
void OMPClauseEnqueue::VisitOMPReductionClause(const OMPReductionClause *C) {
VisitOMPClauseList(C);
- VisitOMPClauseWithPreInit(C);
VisitOMPClauseWithPostUpdate(C);
for (auto *E : C->privates()) {
Visitor->AddStmt(E);
More information about the cfe-commits
mailing list