From 3a0edf1ccbe2869fb92e8cda66da6207c80f3c36 Mon Sep 17 00:00:00 2001 From: Kelvin Li Date: Sat, 15 Sep 2018 13:54:15 +0000 Subject: [PATCH] [OPENMP] Move OMPClauseReader/Writer classes to ASTReader/Writer (NFC) Move declarations for OMPClauseReader, OMPClauseWriter to ASTReader.h and ASTWriter.h and move implementation to ASTReader.cpp and ASTWriter.cpp. This change helps generalize the serialization of OpenMP clauses and will be used in the future implementation of new OpenMP directives (e.g. requires). Patch by Patrick Lyster Differential Revision: https://reviews.llvm.org/D52097 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342322 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/OpenMPClause.h | 37 + include/clang/AST/StmtVisitor.h | 35 - include/clang/Serialization/ASTReader.h | 16 + include/clang/Serialization/ASTWriter.h | 13 + lib/Serialization/ASTReader.cpp | 870 +++++++++++++++++++++++ lib/Serialization/ASTReaderStmt.cpp | 892 +----------------------- lib/Serialization/ASTWriter.cpp | 465 ++++++++++++ lib/Serialization/ASTWriterStmt.cpp | 479 ------------- 8 files changed, 1402 insertions(+), 1405 deletions(-) diff --git a/include/clang/AST/OpenMPClause.h b/include/clang/AST/OpenMPClause.h index 99fa7a3592..f6e0c85267 100644 --- a/include/clang/AST/OpenMPClause.h +++ b/include/clang/AST/OpenMPClause.h @@ -5041,6 +5041,43 @@ public: } }; +/// This class implements a simple visitor for OMPClause +/// subclasses. +template class Ptr, typename RetTy> +class OMPClauseVisitorBase { +public: +#define PTR(CLASS) typename Ptr::type +#define DISPATCH(CLASS) \ + return static_cast(this)->Visit##CLASS(static_cast(S)) + +#define OPENMP_CLAUSE(Name, Class) \ + RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); } +#include "clang/Basic/OpenMPKinds.def" + + RetTy Visit(PTR(OMPClause) S) { + // Top switch clause: visit each OMPClause. + switch (S->getClauseKind()) { + default: llvm_unreachable("Unknown clause kind!"); +#define OPENMP_CLAUSE(Name, Class) \ + case OMPC_ ## Name : return Visit ## Class(static_cast(S)); +#include "clang/Basic/OpenMPKinds.def" + } + } + // Base case, ignore it. :) + RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); } +#undef PTR +#undef DISPATCH +}; + +template +using const_ptr = typename std::add_pointer::type>; + +template +class OMPClauseVisitor : + public OMPClauseVisitorBase {}; +template +class ConstOMPClauseVisitor : + public OMPClauseVisitorBase {}; } // namespace clang #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H diff --git a/include/clang/AST/StmtVisitor.h b/include/clang/AST/StmtVisitor.h index 30bc257c7e..bbfffe8186 100644 --- a/include/clang/AST/StmtVisitor.h +++ b/include/clang/AST/StmtVisitor.h @@ -195,41 +195,6 @@ template class ConstStmtVisitor : public StmtVisitorBase {}; -/// This class implements a simple visitor for OMPClause -/// subclasses. -template class Ptr, typename RetTy> -class OMPClauseVisitorBase { -public: -#define PTR(CLASS) typename Ptr::type -#define DISPATCH(CLASS) \ - return static_cast(this)->Visit##CLASS(static_cast(S)) - -#define OPENMP_CLAUSE(Name, Class) \ - RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); } -#include "clang/Basic/OpenMPKinds.def" - - RetTy Visit(PTR(OMPClause) S) { - // Top switch clause: visit each OMPClause. - switch (S->getClauseKind()) { - default: llvm_unreachable("Unknown clause kind!"); -#define OPENMP_CLAUSE(Name, Class) \ - case OMPC_ ## Name : return Visit ## Class(static_cast(S)); -#include "clang/Basic/OpenMPKinds.def" - } - } - // Base case, ignore it. :) - RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); } -#undef PTR -#undef DISPATCH -}; - -template -class OMPClauseVisitor : - public OMPClauseVisitorBase {}; -template -class ConstOMPClauseVisitor : - public OMPClauseVisitorBase {}; - } // namespace clang #endif // LLVM_CLANG_AST_STMTVISITOR_H diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 98f8f5af48..f97f545852 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -18,6 +18,7 @@ #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/NestedNameSpecifier.h" +#include "clang/AST/OpenMPClause.h" #include "clang/AST/TemplateBase.h" #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" @@ -2677,6 +2678,21 @@ inline void PCHValidator::Error(const char *Msg) { Reader.Error(Msg); } +class OMPClauseReader : public OMPClauseVisitor { + ASTRecordReader &Record; + ASTContext &Context; + +public: + OMPClauseReader(ASTRecordReader &Record) + : Record(Record), Context(Record.getContext()) {} + +#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C); +#include "clang/Basic/OpenMPKinds.def" + OMPClause *readClause(); + void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C); + void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C); +}; + } // namespace clang #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index 1a89a9e14a..da8b10a3f4 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -19,6 +19,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/NestedNameSpecifier.h" +#include "clang/AST/OpenMPClause.h" #include "clang/AST/TemplateBase.h" #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" @@ -993,6 +994,18 @@ public: bool hasEmittedPCH() const { return Buffer->IsComplete; } }; +class OMPClauseWriter : public OMPClauseVisitor { + ASTRecordWriter &Record; + +public: + OMPClauseWriter(ASTRecordWriter &Record) : Record(Record) {} +#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S); +#include "clang/Basic/OpenMPKinds.def" + void writeClause(OMPClause *C); + void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C); + void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C); +}; + } // namespace clang #endif // LLVM_CLANG_SERIALIZATION_ASTWRITER_H diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index ac3b737401..bb2076e25f 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -11651,3 +11651,873 @@ unsigned ASTRecordReader::readRecord(llvm::BitstreamCursor &Cursor, Record.clear(); return Cursor.readRecord(AbbrevID, Record); } +//===----------------------------------------------------------------------===// +//// OMPClauseReader implementation +////===----------------------------------------------------------------------===// + +OMPClause *OMPClauseReader::readClause() { + OMPClause *C; + switch (Record.readInt()) { + case OMPC_if: + C = new (Context) OMPIfClause(); + break; + case OMPC_final: + C = new (Context) OMPFinalClause(); + break; + case OMPC_num_threads: + C = new (Context) OMPNumThreadsClause(); + break; + case OMPC_safelen: + C = new (Context) OMPSafelenClause(); + break; + case OMPC_simdlen: + C = new (Context) OMPSimdlenClause(); + break; + case OMPC_collapse: + C = new (Context) OMPCollapseClause(); + break; + case OMPC_default: + C = new (Context) OMPDefaultClause(); + break; + case OMPC_proc_bind: + C = new (Context) OMPProcBindClause(); + break; + case OMPC_schedule: + C = new (Context) OMPScheduleClause(); + break; + case OMPC_ordered: + C = OMPOrderedClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_nowait: + C = new (Context) OMPNowaitClause(); + break; + case OMPC_untied: + C = new (Context) OMPUntiedClause(); + break; + case OMPC_mergeable: + C = new (Context) OMPMergeableClause(); + break; + case OMPC_read: + C = new (Context) OMPReadClause(); + break; + case OMPC_write: + C = new (Context) OMPWriteClause(); + break; + case OMPC_update: + C = new (Context) OMPUpdateClause(); + break; + case OMPC_capture: + C = new (Context) OMPCaptureClause(); + break; + case OMPC_seq_cst: + C = new (Context) OMPSeqCstClause(); + break; + case OMPC_threads: + C = new (Context) OMPThreadsClause(); + break; + case OMPC_simd: + C = new (Context) OMPSIMDClause(); + break; + case OMPC_nogroup: + C = new (Context) OMPNogroupClause(); + break; + case OMPC_private: + C = OMPPrivateClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_firstprivate: + C = OMPFirstprivateClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_lastprivate: + C = OMPLastprivateClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_shared: + C = OMPSharedClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_reduction: + C = OMPReductionClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_task_reduction: + C = OMPTaskReductionClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_in_reduction: + C = OMPInReductionClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_linear: + C = OMPLinearClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_aligned: + C = OMPAlignedClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_copyin: + C = OMPCopyinClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_copyprivate: + C = OMPCopyprivateClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_flush: + C = OMPFlushClause::CreateEmpty(Context, Record.readInt()); + break; + case OMPC_depend: { + unsigned NumVars = Record.readInt(); + unsigned NumLoops = Record.readInt(); + C = OMPDependClause::CreateEmpty(Context, NumVars, NumLoops); + break; + } + case OMPC_device: + C = new (Context) OMPDeviceClause(); + break; + case OMPC_map: { + unsigned NumVars = Record.readInt(); + unsigned NumDeclarations = Record.readInt(); + unsigned NumLists = Record.readInt(); + unsigned NumComponents = Record.readInt(); + C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, + NumComponents); + break; + } + case OMPC_num_teams: + C = new (Context) OMPNumTeamsClause(); + break; + case OMPC_thread_limit: + C = new (Context) OMPThreadLimitClause(); + break; + case OMPC_priority: + C = new (Context) OMPPriorityClause(); + break; + case OMPC_grainsize: + C = new (Context) OMPGrainsizeClause(); + break; + case OMPC_num_tasks: + C = new (Context) OMPNumTasksClause(); + break; + case OMPC_hint: + C = new (Context) OMPHintClause(); + break; + case OMPC_dist_schedule: + C = new (Context) OMPDistScheduleClause(); + break; + case OMPC_defaultmap: + C = new (Context) OMPDefaultmapClause(); + break; + case OMPC_to: { + unsigned NumVars = Record.readInt(); + unsigned NumDeclarations = Record.readInt(); + unsigned NumLists = Record.readInt(); + unsigned NumComponents = Record.readInt(); + C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, + NumComponents); + break; + } + case OMPC_from: { + unsigned NumVars = Record.readInt(); + unsigned NumDeclarations = Record.readInt(); + unsigned NumLists = Record.readInt(); + unsigned NumComponents = Record.readInt(); + C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, + NumComponents); + break; + } + case OMPC_use_device_ptr: { + unsigned NumVars = Record.readInt(); + unsigned NumDeclarations = Record.readInt(); + unsigned NumLists = Record.readInt(); + unsigned NumComponents = Record.readInt(); + C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, + NumLists, NumComponents); + break; + } + case OMPC_is_device_ptr: { + unsigned NumVars = Record.readInt(); + unsigned NumDeclarations = Record.readInt(); + unsigned NumLists = Record.readInt(); + unsigned NumComponents = Record.readInt(); + C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, + NumLists, NumComponents); + break; + } + } + Visit(C); + C->setLocStart(Record.readSourceLocation()); + C->setLocEnd(Record.readSourceLocation()); + + return C; +} + +void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) { + C->setPreInitStmt(Record.readSubStmt(), + static_cast(Record.readInt())); +} + +void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) { + VisitOMPClauseWithPreInit(C); + C->setPostUpdateExpr(Record.readSubExpr()); +} + +void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) { + VisitOMPClauseWithPreInit(C); + C->setNameModifier(static_cast(Record.readInt())); + C->setNameModifierLoc(Record.readSourceLocation()); + C->setColonLoc(Record.readSourceLocation()); + C->setCondition(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) { + C->setCondition(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) { + VisitOMPClauseWithPreInit(C); + C->setNumThreads(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) { + C->setSafelen(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) { + C->setSimdlen(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) { + C->setNumForLoops(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) { + C->setDefaultKind( + static_cast(Record.readInt())); + C->setLParenLoc(Record.readSourceLocation()); + C->setDefaultKindKwLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) { + C->setProcBindKind( + static_cast(Record.readInt())); + C->setLParenLoc(Record.readSourceLocation()); + C->setProcBindKindKwLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) { + VisitOMPClauseWithPreInit(C); + C->setScheduleKind( + static_cast(Record.readInt())); + C->setFirstScheduleModifier( + static_cast(Record.readInt())); + C->setSecondScheduleModifier( + static_cast(Record.readInt())); + C->setChunkSize(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); + C->setFirstScheduleModifierLoc(Record.readSourceLocation()); + C->setSecondScheduleModifierLoc(Record.readSourceLocation()); + C->setScheduleKindLoc(Record.readSourceLocation()); + C->setCommaLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) { + C->setNumForLoops(Record.readSubExpr()); + for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I) + C->setLoopNumIterations(I, Record.readSubExpr()); + for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I) + C->setLoopCounter(I, Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {} + +void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {} + +void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {} + +void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {} + +void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {} + +void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {} + +void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {} + +void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {} + +void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {} + +void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {} + +void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {} + +void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setPrivateCopies(Vars); +} + +void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) { + VisitOMPClauseWithPreInit(C); + C->setLParenLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setPrivateCopies(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setInits(Vars); +} + +void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) { + VisitOMPClauseWithPostUpdate(C); + C->setLParenLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setPrivateCopies(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setSourceExprs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setDestinationExprs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setAssignmentOps(Vars); +} + +void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); +} + +void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) { + VisitOMPClauseWithPostUpdate(C); + C->setLParenLoc(Record.readSourceLocation()); + C->setColonLoc(Record.readSourceLocation()); + NestedNameSpecifierLoc NNSL = Record.readNestedNameSpecifierLoc(); + DeclarationNameInfo DNI; + Record.readDeclarationNameInfo(DNI); + C->setQualifierLoc(NNSL); + C->setNameInfo(DNI); + + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setPrivates(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setLHSExprs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setRHSExprs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setReductionOps(Vars); +} + +void OMPClauseReader::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) { + VisitOMPClauseWithPostUpdate(C); + C->setLParenLoc(Record.readSourceLocation()); + C->setColonLoc(Record.readSourceLocation()); + NestedNameSpecifierLoc NNSL = Record.readNestedNameSpecifierLoc(); + DeclarationNameInfo DNI; + Record.readDeclarationNameInfo(DNI); + C->setQualifierLoc(NNSL); + C->setNameInfo(DNI); + + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + Vars.clear(); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setPrivates(Vars); + Vars.clear(); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setLHSExprs(Vars); + Vars.clear(); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setRHSExprs(Vars); + Vars.clear(); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setReductionOps(Vars); +} + +void OMPClauseReader::VisitOMPInReductionClause(OMPInReductionClause *C) { + VisitOMPClauseWithPostUpdate(C); + C->setLParenLoc(Record.readSourceLocation()); + C->setColonLoc(Record.readSourceLocation()); + NestedNameSpecifierLoc NNSL = Record.readNestedNameSpecifierLoc(); + DeclarationNameInfo DNI; + Record.readDeclarationNameInfo(DNI); + C->setQualifierLoc(NNSL); + C->setNameInfo(DNI); + + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + Vars.clear(); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setPrivates(Vars); + Vars.clear(); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setLHSExprs(Vars); + Vars.clear(); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setRHSExprs(Vars); + Vars.clear(); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setReductionOps(Vars); + Vars.clear(); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setTaskgroupDescriptors(Vars); +} + +void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) { + VisitOMPClauseWithPostUpdate(C); + C->setLParenLoc(Record.readSourceLocation()); + C->setColonLoc(Record.readSourceLocation()); + C->setModifier(static_cast(Record.readInt())); + C->setModifierLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setPrivates(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setInits(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setUpdates(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setFinals(Vars); + C->setStep(Record.readSubExpr()); + C->setCalcStep(Record.readSubExpr()); +} + +void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + C->setColonLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + C->setAlignment(Record.readSubExpr()); +} + +void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Exprs; + Exprs.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Exprs.push_back(Record.readSubExpr()); + C->setVarRefs(Exprs); + Exprs.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Exprs.push_back(Record.readSubExpr()); + C->setSourceExprs(Exprs); + Exprs.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Exprs.push_back(Record.readSubExpr()); + C->setDestinationExprs(Exprs); + Exprs.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Exprs.push_back(Record.readSubExpr()); + C->setAssignmentOps(Exprs); +} + +void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Exprs; + Exprs.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Exprs.push_back(Record.readSubExpr()); + C->setVarRefs(Exprs); + Exprs.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Exprs.push_back(Record.readSubExpr()); + C->setSourceExprs(Exprs); + Exprs.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Exprs.push_back(Record.readSubExpr()); + C->setDestinationExprs(Exprs); + Exprs.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Exprs.push_back(Record.readSubExpr()); + C->setAssignmentOps(Exprs); +} + +void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); +} + +void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + C->setDependencyKind( + static_cast(Record.readInt())); + C->setDependencyLoc(Record.readSourceLocation()); + C->setColonLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned I = 0; I != NumVars; ++I) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I) + C->setLoopData(I, Record.readSubExpr()); +} + +void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) { + VisitOMPClauseWithPreInit(C); + C->setDevice(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + C->setMapTypeModifier( + static_cast(Record.readInt())); + C->setMapType( + static_cast(Record.readInt())); + C->setMapLoc(Record.readSourceLocation()); + C->setColonLoc(Record.readSourceLocation()); + auto NumVars = C->varlist_size(); + auto UniqueDecls = C->getUniqueDeclarationsNum(); + auto TotalLists = C->getTotalComponentListNum(); + auto TotalComponents = C->getTotalComponentsNum(); + + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + + SmallVector Decls; + Decls.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + Decls.push_back(Record.readDeclAs()); + C->setUniqueDecls(Decls); + + SmallVector ListsPerDecl; + ListsPerDecl.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + ListsPerDecl.push_back(Record.readInt()); + C->setDeclNumLists(ListsPerDecl); + + SmallVector ListSizes; + ListSizes.reserve(TotalLists); + for (unsigned i = 0; i < TotalLists; ++i) + ListSizes.push_back(Record.readInt()); + C->setComponentListSizes(ListSizes); + + SmallVector Components; + Components.reserve(TotalComponents); + for (unsigned i = 0; i < TotalComponents; ++i) { + Expr *AssociatedExpr = Record.readSubExpr(); + auto *AssociatedDecl = Record.readDeclAs(); + Components.push_back(OMPClauseMappableExprCommon::MappableComponent( + AssociatedExpr, AssociatedDecl)); + } + C->setComponents(Components, ListSizes); +} + +void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) { + VisitOMPClauseWithPreInit(C); + C->setNumTeams(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) { + VisitOMPClauseWithPreInit(C); + C->setThreadLimit(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) { + C->setPriority(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) { + C->setGrainsize(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) { + C->setNumTasks(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) { + C->setHint(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) { + VisitOMPClauseWithPreInit(C); + C->setDistScheduleKind( + static_cast(Record.readInt())); + C->setChunkSize(Record.readSubExpr()); + C->setLParenLoc(Record.readSourceLocation()); + C->setDistScheduleKindLoc(Record.readSourceLocation()); + C->setCommaLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) { + C->setDefaultmapKind( + static_cast(Record.readInt())); + C->setDefaultmapModifier( + static_cast(Record.readInt())); + C->setLParenLoc(Record.readSourceLocation()); + C->setDefaultmapModifierLoc(Record.readSourceLocation()); + C->setDefaultmapKindLoc(Record.readSourceLocation()); +} + +void OMPClauseReader::VisitOMPToClause(OMPToClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + auto NumVars = C->varlist_size(); + auto UniqueDecls = C->getUniqueDeclarationsNum(); + auto TotalLists = C->getTotalComponentListNum(); + auto TotalComponents = C->getTotalComponentsNum(); + + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + + SmallVector Decls; + Decls.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + Decls.push_back(Record.readDeclAs()); + C->setUniqueDecls(Decls); + + SmallVector ListsPerDecl; + ListsPerDecl.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + ListsPerDecl.push_back(Record.readInt()); + C->setDeclNumLists(ListsPerDecl); + + SmallVector ListSizes; + ListSizes.reserve(TotalLists); + for (unsigned i = 0; i < TotalLists; ++i) + ListSizes.push_back(Record.readInt()); + C->setComponentListSizes(ListSizes); + + SmallVector Components; + Components.reserve(TotalComponents); + for (unsigned i = 0; i < TotalComponents; ++i) { + Expr *AssociatedExpr = Record.readSubExpr(); + auto *AssociatedDecl = Record.readDeclAs(); + Components.push_back(OMPClauseMappableExprCommon::MappableComponent( + AssociatedExpr, AssociatedDecl)); + } + C->setComponents(Components, ListSizes); +} + +void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + auto NumVars = C->varlist_size(); + auto UniqueDecls = C->getUniqueDeclarationsNum(); + auto TotalLists = C->getTotalComponentListNum(); + auto TotalComponents = C->getTotalComponentsNum(); + + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + + SmallVector Decls; + Decls.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + Decls.push_back(Record.readDeclAs()); + C->setUniqueDecls(Decls); + + SmallVector ListsPerDecl; + ListsPerDecl.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + ListsPerDecl.push_back(Record.readInt()); + C->setDeclNumLists(ListsPerDecl); + + SmallVector ListSizes; + ListSizes.reserve(TotalLists); + for (unsigned i = 0; i < TotalLists; ++i) + ListSizes.push_back(Record.readInt()); + C->setComponentListSizes(ListSizes); + + SmallVector Components; + Components.reserve(TotalComponents); + for (unsigned i = 0; i < TotalComponents; ++i) { + Expr *AssociatedExpr = Record.readSubExpr(); + auto *AssociatedDecl = Record.readDeclAs(); + Components.push_back(OMPClauseMappableExprCommon::MappableComponent( + AssociatedExpr, AssociatedDecl)); + } + C->setComponents(Components, ListSizes); +} + +void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + auto NumVars = C->varlist_size(); + auto UniqueDecls = C->getUniqueDeclarationsNum(); + auto TotalLists = C->getTotalComponentListNum(); + auto TotalComponents = C->getTotalComponentsNum(); + + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setPrivateCopies(Vars); + Vars.clear(); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setInits(Vars); + + SmallVector Decls; + Decls.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + Decls.push_back(Record.readDeclAs()); + C->setUniqueDecls(Decls); + + SmallVector ListsPerDecl; + ListsPerDecl.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + ListsPerDecl.push_back(Record.readInt()); + C->setDeclNumLists(ListsPerDecl); + + SmallVector ListSizes; + ListSizes.reserve(TotalLists); + for (unsigned i = 0; i < TotalLists; ++i) + ListSizes.push_back(Record.readInt()); + C->setComponentListSizes(ListSizes); + + SmallVector Components; + Components.reserve(TotalComponents); + for (unsigned i = 0; i < TotalComponents; ++i) { + Expr *AssociatedExpr = Record.readSubExpr(); + auto *AssociatedDecl = Record.readDeclAs(); + Components.push_back(OMPClauseMappableExprCommon::MappableComponent( + AssociatedExpr, AssociatedDecl)); + } + C->setComponents(Components, ListSizes); +} + +void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { + C->setLParenLoc(Record.readSourceLocation()); + auto NumVars = C->varlist_size(); + auto UniqueDecls = C->getUniqueDeclarationsNum(); + auto TotalLists = C->getTotalComponentListNum(); + auto TotalComponents = C->getTotalComponentsNum(); + + SmallVector Vars; + Vars.reserve(NumVars); + for (unsigned i = 0; i != NumVars; ++i) + Vars.push_back(Record.readSubExpr()); + C->setVarRefs(Vars); + Vars.clear(); + + SmallVector Decls; + Decls.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + Decls.push_back(Record.readDeclAs()); + C->setUniqueDecls(Decls); + + SmallVector ListsPerDecl; + ListsPerDecl.reserve(UniqueDecls); + for (unsigned i = 0; i < UniqueDecls; ++i) + ListsPerDecl.push_back(Record.readInt()); + C->setDeclNumLists(ListsPerDecl); + + SmallVector ListSizes; + ListSizes.reserve(TotalLists); + for (unsigned i = 0; i < TotalLists; ++i) + ListSizes.push_back(Record.readInt()); + C->setComponentListSizes(ListSizes); + + SmallVector Components; + Components.reserve(TotalComponents); + for (unsigned i = 0; i < TotalComponents; ++i) { + Expr *AssociatedExpr = Record.readSubExpr(); + auto *AssociatedDecl = Record.readDeclAs(); + Components.push_back(OMPClauseMappableExprCommon::MappableComponent( + AssociatedExpr, AssociatedDecl)); + } + C->setComponents(Components, ListSizes); +} diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index 570b554986..0d83b8aac9 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -1802,896 +1802,6 @@ void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) { E->SrcExpr = Record.readSubExpr(); } -//===----------------------------------------------------------------------===// -// OpenMP Clauses. -//===----------------------------------------------------------------------===// - -namespace clang { - -class OMPClauseReader : public OMPClauseVisitor { - ASTStmtReader *Reader; - ASTContext &Context; - -public: - OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record) - : Reader(R), Context(Record.getContext()) {} - -#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C); -#include "clang/Basic/OpenMPKinds.def" - OMPClause *readClause(); - void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C); - void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C); -}; - -} // namespace clang - -OMPClause *OMPClauseReader::readClause() { - OMPClause *C; - switch (Reader->Record.readInt()) { - case OMPC_if: - C = new (Context) OMPIfClause(); - break; - case OMPC_final: - C = new (Context) OMPFinalClause(); - break; - case OMPC_num_threads: - C = new (Context) OMPNumThreadsClause(); - break; - case OMPC_safelen: - C = new (Context) OMPSafelenClause(); - break; - case OMPC_simdlen: - C = new (Context) OMPSimdlenClause(); - break; - case OMPC_collapse: - C = new (Context) OMPCollapseClause(); - break; - case OMPC_default: - C = new (Context) OMPDefaultClause(); - break; - case OMPC_proc_bind: - C = new (Context) OMPProcBindClause(); - break; - case OMPC_schedule: - C = new (Context) OMPScheduleClause(); - break; - case OMPC_ordered: - C = OMPOrderedClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_nowait: - C = new (Context) OMPNowaitClause(); - break; - case OMPC_untied: - C = new (Context) OMPUntiedClause(); - break; - case OMPC_mergeable: - C = new (Context) OMPMergeableClause(); - break; - case OMPC_read: - C = new (Context) OMPReadClause(); - break; - case OMPC_write: - C = new (Context) OMPWriteClause(); - break; - case OMPC_update: - C = new (Context) OMPUpdateClause(); - break; - case OMPC_capture: - C = new (Context) OMPCaptureClause(); - break; - case OMPC_seq_cst: - C = new (Context) OMPSeqCstClause(); - break; - case OMPC_threads: - C = new (Context) OMPThreadsClause(); - break; - case OMPC_simd: - C = new (Context) OMPSIMDClause(); - break; - case OMPC_nogroup: - C = new (Context) OMPNogroupClause(); - break; - case OMPC_private: - C = OMPPrivateClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_firstprivate: - C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_lastprivate: - C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_shared: - C = OMPSharedClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_reduction: - C = OMPReductionClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_task_reduction: - C = OMPTaskReductionClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_in_reduction: - C = OMPInReductionClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_linear: - C = OMPLinearClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_aligned: - C = OMPAlignedClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_copyin: - C = OMPCopyinClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_copyprivate: - C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_flush: - C = OMPFlushClause::CreateEmpty(Context, Reader->Record.readInt()); - break; - case OMPC_depend: { - unsigned NumVars = Reader->Record.readInt(); - unsigned NumLoops = Reader->Record.readInt(); - C = OMPDependClause::CreateEmpty(Context, NumVars, NumLoops); - break; - } - case OMPC_device: - C = new (Context) OMPDeviceClause(); - break; - case OMPC_map: { - unsigned NumVars = Reader->Record.readInt(); - unsigned NumDeclarations = Reader->Record.readInt(); - unsigned NumLists = Reader->Record.readInt(); - unsigned NumComponents = Reader->Record.readInt(); - C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, - NumComponents); - break; - } - case OMPC_num_teams: - C = new (Context) OMPNumTeamsClause(); - break; - case OMPC_thread_limit: - C = new (Context) OMPThreadLimitClause(); - break; - case OMPC_priority: - C = new (Context) OMPPriorityClause(); - break; - case OMPC_grainsize: - C = new (Context) OMPGrainsizeClause(); - break; - case OMPC_num_tasks: - C = new (Context) OMPNumTasksClause(); - break; - case OMPC_hint: - C = new (Context) OMPHintClause(); - break; - case OMPC_dist_schedule: - C = new (Context) OMPDistScheduleClause(); - break; - case OMPC_defaultmap: - C = new (Context) OMPDefaultmapClause(); - break; - case OMPC_to: { - unsigned NumVars = Reader->Record.readInt(); - unsigned NumDeclarations = Reader->Record.readInt(); - unsigned NumLists = Reader->Record.readInt(); - unsigned NumComponents = Reader->Record.readInt(); - C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, - NumComponents); - break; - } - case OMPC_from: { - unsigned NumVars = Reader->Record.readInt(); - unsigned NumDeclarations = Reader->Record.readInt(); - unsigned NumLists = Reader->Record.readInt(); - unsigned NumComponents = Reader->Record.readInt(); - C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, - NumComponents); - break; - } - case OMPC_use_device_ptr: { - unsigned NumVars = Reader->Record.readInt(); - unsigned NumDeclarations = Reader->Record.readInt(); - unsigned NumLists = Reader->Record.readInt(); - unsigned NumComponents = Reader->Record.readInt(); - C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, - NumLists, NumComponents); - break; - } - case OMPC_is_device_ptr: { - unsigned NumVars = Reader->Record.readInt(); - unsigned NumDeclarations = Reader->Record.readInt(); - unsigned NumLists = Reader->Record.readInt(); - unsigned NumComponents = Reader->Record.readInt(); - C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, - NumLists, NumComponents); - break; - } - } - Visit(C); - C->setLocStart(Reader->ReadSourceLocation()); - C->setLocEnd(Reader->ReadSourceLocation()); - - return C; -} - -void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) { - C->setPreInitStmt(Reader->Record.readSubStmt(), - static_cast(Reader->Record.readInt())); -} - -void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) { - VisitOMPClauseWithPreInit(C); - C->setPostUpdateExpr(Reader->Record.readSubExpr()); -} - -void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) { - VisitOMPClauseWithPreInit(C); - C->setNameModifier(static_cast(Reader->Record.readInt())); - C->setNameModifierLoc(Reader->ReadSourceLocation()); - C->setColonLoc(Reader->ReadSourceLocation()); - C->setCondition(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) { - C->setCondition(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) { - VisitOMPClauseWithPreInit(C); - C->setNumThreads(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) { - C->setSafelen(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) { - C->setSimdlen(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) { - C->setNumForLoops(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) { - C->setDefaultKind( - static_cast(Reader->Record.readInt())); - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setDefaultKindKwLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) { - C->setProcBindKind( - static_cast(Reader->Record.readInt())); - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setProcBindKindKwLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) { - VisitOMPClauseWithPreInit(C); - C->setScheduleKind( - static_cast(Reader->Record.readInt())); - C->setFirstScheduleModifier( - static_cast(Reader->Record.readInt())); - C->setSecondScheduleModifier( - static_cast(Reader->Record.readInt())); - C->setChunkSize(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation()); - C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation()); - C->setScheduleKindLoc(Reader->ReadSourceLocation()); - C->setCommaLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) { - C->setNumForLoops(Reader->Record.readSubExpr()); - for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I) - C->setLoopNumIterations(I, Reader->Record.readSubExpr()); - for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I) - C->setLoopCounter(I, Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {} - -void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {} - -void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {} - -void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {} - -void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {} - -void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {} - -void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {} - -void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {} - -void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {} - -void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {} - -void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {} - -void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setPrivateCopies(Vars); -} - -void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) { - VisitOMPClauseWithPreInit(C); - C->setLParenLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setPrivateCopies(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setInits(Vars); -} - -void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) { - VisitOMPClauseWithPostUpdate(C); - C->setLParenLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setPrivateCopies(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setSourceExprs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setDestinationExprs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setAssignmentOps(Vars); -} - -void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); -} - -void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) { - VisitOMPClauseWithPostUpdate(C); - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setColonLoc(Reader->ReadSourceLocation()); - NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc(); - DeclarationNameInfo DNI; - Reader->ReadDeclarationNameInfo(DNI); - C->setQualifierLoc(NNSL); - C->setNameInfo(DNI); - - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setPrivates(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setLHSExprs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setRHSExprs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setReductionOps(Vars); -} - -void OMPClauseReader::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) { - VisitOMPClauseWithPostUpdate(C); - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setColonLoc(Reader->ReadSourceLocation()); - NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc(); - DeclarationNameInfo DNI; - Reader->ReadDeclarationNameInfo(DNI); - C->setQualifierLoc(NNSL); - C->setNameInfo(DNI); - - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - Vars.clear(); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setPrivates(Vars); - Vars.clear(); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setLHSExprs(Vars); - Vars.clear(); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setRHSExprs(Vars); - Vars.clear(); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setReductionOps(Vars); -} - -void OMPClauseReader::VisitOMPInReductionClause(OMPInReductionClause *C) { - VisitOMPClauseWithPostUpdate(C); - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setColonLoc(Reader->ReadSourceLocation()); - NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc(); - DeclarationNameInfo DNI; - Reader->ReadDeclarationNameInfo(DNI); - C->setQualifierLoc(NNSL); - C->setNameInfo(DNI); - - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - Vars.clear(); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setPrivates(Vars); - Vars.clear(); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setLHSExprs(Vars); - Vars.clear(); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setRHSExprs(Vars); - Vars.clear(); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setReductionOps(Vars); - Vars.clear(); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setTaskgroupDescriptors(Vars); -} - -void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) { - VisitOMPClauseWithPostUpdate(C); - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setColonLoc(Reader->ReadSourceLocation()); - C->setModifier(static_cast(Reader->Record.readInt())); - C->setModifierLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setPrivates(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setInits(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setUpdates(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setFinals(Vars); - C->setStep(Reader->Record.readSubExpr()); - C->setCalcStep(Reader->Record.readSubExpr()); -} - -void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setColonLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - C->setAlignment(Reader->Record.readSubExpr()); -} - -void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Exprs; - Exprs.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Exprs); - Exprs.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Record.readSubExpr()); - C->setSourceExprs(Exprs); - Exprs.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Record.readSubExpr()); - C->setDestinationExprs(Exprs); - Exprs.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Record.readSubExpr()); - C->setAssignmentOps(Exprs); -} - -void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Exprs; - Exprs.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Exprs); - Exprs.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Record.readSubExpr()); - C->setSourceExprs(Exprs); - Exprs.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Record.readSubExpr()); - C->setDestinationExprs(Exprs); - Exprs.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Record.readSubExpr()); - C->setAssignmentOps(Exprs); -} - -void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); -} - -void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setDependencyKind( - static_cast(Reader->Record.readInt())); - C->setDependencyLoc(Reader->ReadSourceLocation()); - C->setColonLoc(Reader->ReadSourceLocation()); - unsigned NumVars = C->varlist_size(); - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned I = 0; I != NumVars; ++I) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I) - C->setLoopData(I, Reader->Record.readSubExpr()); -} - -void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) { - VisitOMPClauseWithPreInit(C); - C->setDevice(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setMapTypeModifier( - static_cast(Reader->Record.readInt())); - C->setMapType( - static_cast(Reader->Record.readInt())); - C->setMapLoc(Reader->ReadSourceLocation()); - C->setColonLoc(Reader->ReadSourceLocation()); - auto NumVars = C->varlist_size(); - auto UniqueDecls = C->getUniqueDeclarationsNum(); - auto TotalLists = C->getTotalComponentListNum(); - auto TotalComponents = C->getTotalComponentsNum(); - - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - - SmallVector Decls; - Decls.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.readDeclAs()); - C->setUniqueDecls(Decls); - - SmallVector ListsPerDecl; - ListsPerDecl.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Reader->Record.readInt()); - C->setDeclNumLists(ListsPerDecl); - - SmallVector ListSizes; - ListSizes.reserve(TotalLists); - for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Reader->Record.readInt()); - C->setComponentListSizes(ListSizes); - - SmallVector Components; - Components.reserve(TotalComponents); - for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Record.readSubExpr(); - auto *AssociatedDecl = Reader->Record.readDeclAs(); - Components.push_back(OMPClauseMappableExprCommon::MappableComponent( - AssociatedExpr, AssociatedDecl)); - } - C->setComponents(Components, ListSizes); -} - -void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) { - VisitOMPClauseWithPreInit(C); - C->setNumTeams(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) { - VisitOMPClauseWithPreInit(C); - C->setThreadLimit(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) { - C->setPriority(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) { - C->setGrainsize(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) { - C->setNumTasks(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) { - C->setHint(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) { - VisitOMPClauseWithPreInit(C); - C->setDistScheduleKind( - static_cast(Reader->Record.readInt())); - C->setChunkSize(Reader->Record.readSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setDistScheduleKindLoc(Reader->ReadSourceLocation()); - C->setCommaLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) { - C->setDefaultmapKind( - static_cast(Reader->Record.readInt())); - C->setDefaultmapModifier( - static_cast(Reader->Record.readInt())); - C->setLParenLoc(Reader->ReadSourceLocation()); - C->setDefaultmapModifierLoc(Reader->ReadSourceLocation()); - C->setDefaultmapKindLoc(Reader->ReadSourceLocation()); -} - -void OMPClauseReader::VisitOMPToClause(OMPToClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - auto NumVars = C->varlist_size(); - auto UniqueDecls = C->getUniqueDeclarationsNum(); - auto TotalLists = C->getTotalComponentListNum(); - auto TotalComponents = C->getTotalComponentsNum(); - - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - - SmallVector Decls; - Decls.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.readDeclAs()); - C->setUniqueDecls(Decls); - - SmallVector ListsPerDecl; - ListsPerDecl.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Reader->Record.readInt()); - C->setDeclNumLists(ListsPerDecl); - - SmallVector ListSizes; - ListSizes.reserve(TotalLists); - for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Reader->Record.readInt()); - C->setComponentListSizes(ListSizes); - - SmallVector Components; - Components.reserve(TotalComponents); - for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Record.readSubExpr(); - auto *AssociatedDecl = Reader->Record.readDeclAs(); - Components.push_back(OMPClauseMappableExprCommon::MappableComponent( - AssociatedExpr, AssociatedDecl)); - } - C->setComponents(Components, ListSizes); -} - -void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - auto NumVars = C->varlist_size(); - auto UniqueDecls = C->getUniqueDeclarationsNum(); - auto TotalLists = C->getTotalComponentListNum(); - auto TotalComponents = C->getTotalComponentsNum(); - - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - - SmallVector Decls; - Decls.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.readDeclAs()); - C->setUniqueDecls(Decls); - - SmallVector ListsPerDecl; - ListsPerDecl.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Reader->Record.readInt()); - C->setDeclNumLists(ListsPerDecl); - - SmallVector ListSizes; - ListSizes.reserve(TotalLists); - for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Reader->Record.readInt()); - C->setComponentListSizes(ListSizes); - - SmallVector Components; - Components.reserve(TotalComponents); - for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Record.readSubExpr(); - auto *AssociatedDecl = Reader->Record.readDeclAs(); - Components.push_back(OMPClauseMappableExprCommon::MappableComponent( - AssociatedExpr, AssociatedDecl)); - } - C->setComponents(Components, ListSizes); -} - -void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - auto NumVars = C->varlist_size(); - auto UniqueDecls = C->getUniqueDeclarationsNum(); - auto TotalLists = C->getTotalComponentListNum(); - auto TotalComponents = C->getTotalComponentsNum(); - - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setPrivateCopies(Vars); - Vars.clear(); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setInits(Vars); - - SmallVector Decls; - Decls.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.readDeclAs()); - C->setUniqueDecls(Decls); - - SmallVector ListsPerDecl; - ListsPerDecl.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Reader->Record.readInt()); - C->setDeclNumLists(ListsPerDecl); - - SmallVector ListSizes; - ListSizes.reserve(TotalLists); - for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Reader->Record.readInt()); - C->setComponentListSizes(ListSizes); - - SmallVector Components; - Components.reserve(TotalComponents); - for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Record.readSubExpr(); - auto *AssociatedDecl = Reader->Record.readDeclAs(); - Components.push_back(OMPClauseMappableExprCommon::MappableComponent( - AssociatedExpr, AssociatedDecl)); - } - C->setComponents(Components, ListSizes); -} - -void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation()); - auto NumVars = C->varlist_size(); - auto UniqueDecls = C->getUniqueDeclarationsNum(); - auto TotalLists = C->getTotalComponentListNum(); - auto TotalComponents = C->getTotalComponentsNum(); - - SmallVector Vars; - Vars.reserve(NumVars); - for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Record.readSubExpr()); - C->setVarRefs(Vars); - Vars.clear(); - - SmallVector Decls; - Decls.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.readDeclAs()); - C->setUniqueDecls(Decls); - - SmallVector ListsPerDecl; - ListsPerDecl.reserve(UniqueDecls); - for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Reader->Record.readInt()); - C->setDeclNumLists(ListsPerDecl); - - SmallVector ListSizes; - ListSizes.reserve(TotalLists); - for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Reader->Record.readInt()); - C->setComponentListSizes(ListSizes); - - SmallVector Components; - Components.reserve(TotalComponents); - for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Record.readSubExpr(); - auto *AssociatedDecl = Reader->Record.readDeclAs(); - Components.push_back(OMPClauseMappableExprCommon::MappableComponent( - AssociatedExpr, AssociatedDecl)); - } - C->setComponents(Components, ListSizes); -} - //===----------------------------------------------------------------------===// // OpenMP Directives. //===----------------------------------------------------------------------===// @@ -2699,7 +1809,7 @@ void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) { E->setLocStart(ReadSourceLocation()); E->setLocEnd(ReadSourceLocation()); - OMPClauseReader ClauseReader(this, Record); + OMPClauseReader ClauseReader(Record); SmallVector Clauses; for (unsigned i = 0; i < E->getNumClauses(); ++i) Clauses.push_back(ClauseReader.readClause()); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 1400c873d4..29c3c0ba91 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -6467,3 +6467,468 @@ void ASTWriter::AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD, DeclsToEmitEvenIfUnreferenced.push_back(D); } + +//===----------------------------------------------------------------------===// +//// OMPClause Serialization +////===----------------------------------------------------------------------===// + +void OMPClauseWriter::writeClause(OMPClause *C) { + Record.push_back(C->getClauseKind()); + Visit(C); + Record.AddSourceLocation(C->getBeginLoc()); + Record.AddSourceLocation(C->getEndLoc()); +} + +void OMPClauseWriter::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) { + Record.push_back(C->getCaptureRegion()); + Record.AddStmt(C->getPreInitStmt()); +} + +void OMPClauseWriter::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) { + VisitOMPClauseWithPreInit(C); + Record.AddStmt(C->getPostUpdateExpr()); +} + +void OMPClauseWriter::VisitOMPIfClause(OMPIfClause *C) { + VisitOMPClauseWithPreInit(C); + Record.push_back(C->getNameModifier()); + Record.AddSourceLocation(C->getNameModifierLoc()); + Record.AddSourceLocation(C->getColonLoc()); + Record.AddStmt(C->getCondition()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPFinalClause(OMPFinalClause *C) { + Record.AddStmt(C->getCondition()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) { + VisitOMPClauseWithPreInit(C); + Record.AddStmt(C->getNumThreads()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPSafelenClause(OMPSafelenClause *C) { + Record.AddStmt(C->getSafelen()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPSimdlenClause(OMPSimdlenClause *C) { + Record.AddStmt(C->getSimdlen()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPCollapseClause(OMPCollapseClause *C) { + Record.AddStmt(C->getNumForLoops()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) { + Record.push_back(C->getDefaultKind()); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getDefaultKindKwLoc()); +} + +void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *C) { + Record.push_back(C->getProcBindKind()); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getProcBindKindKwLoc()); +} + +void OMPClauseWriter::VisitOMPScheduleClause(OMPScheduleClause *C) { + VisitOMPClauseWithPreInit(C); + Record.push_back(C->getScheduleKind()); + Record.push_back(C->getFirstScheduleModifier()); + Record.push_back(C->getSecondScheduleModifier()); + Record.AddStmt(C->getChunkSize()); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getFirstScheduleModifierLoc()); + Record.AddSourceLocation(C->getSecondScheduleModifierLoc()); + Record.AddSourceLocation(C->getScheduleKindLoc()); + Record.AddSourceLocation(C->getCommaLoc()); +} + +void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *C) { + Record.push_back(C->getLoopNumIterations().size()); + Record.AddStmt(C->getNumForLoops()); + for (Expr *NumIter : C->getLoopNumIterations()) + Record.AddStmt(NumIter); + for (unsigned I = 0, E = C->getLoopNumIterations().size(); I getLoopCunter(I)); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *) {} + +void OMPClauseWriter::VisitOMPUntiedClause(OMPUntiedClause *) {} + +void OMPClauseWriter::VisitOMPMergeableClause(OMPMergeableClause *) {} + +void OMPClauseWriter::VisitOMPReadClause(OMPReadClause *) {} + +void OMPClauseWriter::VisitOMPWriteClause(OMPWriteClause *) {} + +void OMPClauseWriter::VisitOMPUpdateClause(OMPUpdateClause *) {} + +void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {} + +void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {} + +void OMPClauseWriter::VisitOMPThreadsClause(OMPThreadsClause *) {} + +void OMPClauseWriter::VisitOMPSIMDClause(OMPSIMDClause *) {} + +void OMPClauseWriter::VisitOMPNogroupClause(OMPNogroupClause *) {} + +void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) { + Record.push_back(C->varlist_size()); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *VE : C->varlists()) { + Record.AddStmt(VE); + } + for (auto *VE : C->private_copies()) { + Record.AddStmt(VE); + } +} + +void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) { + Record.push_back(C->varlist_size()); + VisitOMPClauseWithPreInit(C); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *VE : C->varlists()) { + Record.AddStmt(VE); + } + for (auto *VE : C->private_copies()) { + Record.AddStmt(VE); + } + for (auto *VE : C->inits()) { + Record.AddStmt(VE); + } +} + +void OMPClauseWriter::VisitOMPLastprivateClause(OMPLastprivateClause *C) { + Record.push_back(C->varlist_size()); + VisitOMPClauseWithPostUpdate(C); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); + for (auto *E : C->private_copies()) + Record.AddStmt(E); + for (auto *E : C->source_exprs()) + Record.AddStmt(E); + for (auto *E : C->destination_exprs()) + Record.AddStmt(E); + for (auto *E : C->assignment_ops()) + Record.AddStmt(E); +} + +void OMPClauseWriter::VisitOMPSharedClause(OMPSharedClause *C) { + Record.push_back(C->varlist_size()); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); +} + +void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *C) { + Record.push_back(C->varlist_size()); + VisitOMPClauseWithPostUpdate(C); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getColonLoc()); + Record.AddNestedNameSpecifierLoc(C->getQualifierLoc()); + Record.AddDeclarationNameInfo(C->getNameInfo()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); + for (auto *VE : C->privates()) + Record.AddStmt(VE); + for (auto *E : C->lhs_exprs()) + Record.AddStmt(E); + for (auto *E : C->rhs_exprs()) + Record.AddStmt(E); + for (auto *E : C->reduction_ops()) + Record.AddStmt(E); +} + +void OMPClauseWriter::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) { + Record.push_back(C->varlist_size()); + VisitOMPClauseWithPostUpdate(C); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getColonLoc()); + Record.AddNestedNameSpecifierLoc(C->getQualifierLoc()); + Record.AddDeclarationNameInfo(C->getNameInfo()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); + for (auto *VE : C->privates()) + Record.AddStmt(VE); + for (auto *E : C->lhs_exprs()) + Record.AddStmt(E); + for (auto *E : C->rhs_exprs()) + Record.AddStmt(E); + for (auto *E : C->reduction_ops()) + Record.AddStmt(E); +} + +void OMPClauseWriter::VisitOMPInReductionClause(OMPInReductionClause *C) { + Record.push_back(C->varlist_size()); + VisitOMPClauseWithPostUpdate(C); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getColonLoc()); + Record.AddNestedNameSpecifierLoc(C->getQualifierLoc()); + Record.AddDeclarationNameInfo(C->getNameInfo()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); + for (auto *VE : C->privates()) + Record.AddStmt(VE); + for (auto *E : C->lhs_exprs()) + Record.AddStmt(E); + for (auto *E : C->rhs_exprs()) + Record.AddStmt(E); + for (auto *E : C->reduction_ops()) + Record.AddStmt(E); + for (auto *E : C->taskgroup_descriptors()) + Record.AddStmt(E); +} + +void OMPClauseWriter::VisitOMPLinearClause(OMPLinearClause *C) { + Record.push_back(C->varlist_size()); + VisitOMPClauseWithPostUpdate(C); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getColonLoc()); + Record.push_back(C->getModifier()); + Record.AddSourceLocation(C->getModifierLoc()); + for (auto *VE : C->varlists()) { + Record.AddStmt(VE); + } + for (auto *VE : C->privates()) { + Record.AddStmt(VE); + } + for (auto *VE : C->inits()) { + Record.AddStmt(VE); + } + for (auto *VE : C->updates()) { + Record.AddStmt(VE); + } + for (auto *VE : C->finals()) { + Record.AddStmt(VE); + } + Record.AddStmt(C->getStep()); + Record.AddStmt(C->getCalcStep()); +} + +void OMPClauseWriter::VisitOMPAlignedClause(OMPAlignedClause *C) { + Record.push_back(C->varlist_size()); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getColonLoc()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); + Record.AddStmt(C->getAlignment()); +} + +void OMPClauseWriter::VisitOMPCopyinClause(OMPCopyinClause *C) { + Record.push_back(C->varlist_size()); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); + for (auto *E : C->source_exprs()) + Record.AddStmt(E); + for (auto *E : C->destination_exprs()) + Record.AddStmt(E); + for (auto *E : C->assignment_ops()) + Record.AddStmt(E); +} + +void OMPClauseWriter::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) { + Record.push_back(C->varlist_size()); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); + for (auto *E : C->source_exprs()) + Record.AddStmt(E); + for (auto *E : C->destination_exprs()) + Record.AddStmt(E); + for (auto *E : C->assignment_ops()) + Record.AddStmt(E); +} + +void OMPClauseWriter::VisitOMPFlushClause(OMPFlushClause *C) { + Record.push_back(C->varlist_size()); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); +} + +void OMPClauseWriter::VisitOMPDependClause(OMPDependClause *C) { + Record.push_back(C->varlist_size()); + Record.push_back(C->getNumLoops()); + Record.AddSourceLocation(C->getLParenLoc()); + Record.push_back(C->getDependencyKind()); + Record.AddSourceLocation(C->getDependencyLoc()); + Record.AddSourceLocation(C->getColonLoc()); + for (auto *VE : C->varlists()) + Record.AddStmt(VE); + for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I) + Record.AddStmt(C->getLoopData(I)); +} + +void OMPClauseWriter::VisitOMPDeviceClause(OMPDeviceClause *C) { + VisitOMPClauseWithPreInit(C); + Record.AddStmt(C->getDevice()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *C) { + Record.push_back(C->varlist_size()); + Record.push_back(C->getUniqueDeclarationsNum()); + Record.push_back(C->getTotalComponentListNum()); + Record.push_back(C->getTotalComponentsNum()); + Record.AddSourceLocation(C->getLParenLoc()); + Record.push_back(C->getMapTypeModifier()); + Record.push_back(C->getMapType()); + Record.AddSourceLocation(C->getMapLoc()); + Record.AddSourceLocation(C->getColonLoc()); + for (auto *E : C->varlists()) + Record.AddStmt(E); + for (auto *D : C->all_decls()) + Record.AddDeclRef(D); + for (auto N : C->all_num_lists()) + Record.push_back(N); + for (auto N : C->all_lists_sizes()) + Record.push_back(N); + for (auto &M : C->all_components()) { + Record.AddStmt(M.getAssociatedExpression()); + Record.AddDeclRef(M.getAssociatedDeclaration()); + } +} + +void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) { + VisitOMPClauseWithPreInit(C); + Record.AddStmt(C->getNumTeams()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) { + VisitOMPClauseWithPreInit(C); + Record.AddStmt(C->getThreadLimit()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPPriorityClause(OMPPriorityClause *C) { + Record.AddStmt(C->getPriority()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) { + Record.AddStmt(C->getGrainsize()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPNumTasksClause(OMPNumTasksClause *C) { + Record.AddStmt(C->getNumTasks()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPHintClause(OMPHintClause *C) { + Record.AddStmt(C->getHint()); + Record.AddSourceLocation(C->getLParenLoc()); +} + +void OMPClauseWriter::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) { + VisitOMPClauseWithPreInit(C); + Record.push_back(C->getDistScheduleKind()); + Record.AddStmt(C->getChunkSize()); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getDistScheduleKindLoc()); + Record.AddSourceLocation(C->getCommaLoc()); +} + +void OMPClauseWriter::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) { + Record.push_back(C->getDefaultmapKind()); + Record.push_back(C->getDefaultmapModifier()); + Record.AddSourceLocation(C->getLParenLoc()); + Record.AddSourceLocation(C->getDefaultmapModifierLoc()); + Record.AddSourceLocation(C->getDefaultmapKindLoc()); +} + +void OMPClauseWriter::VisitOMPToClause(OMPToClause *C) { + Record.push_back(C->varlist_size()); + Record.push_back(C->getUniqueDeclarationsNum()); + Record.push_back(C->getTotalComponentListNum()); + Record.push_back(C->getTotalComponentsNum()); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *E : C->varlists()) + Record.AddStmt(E); + for (auto *D : C->all_decls()) + Record.AddDeclRef(D); + for (auto N : C->all_num_lists()) + Record.push_back(N); + for (auto N : C->all_lists_sizes()) + Record.push_back(N); + for (auto &M : C->all_components()) { + Record.AddStmt(M.getAssociatedExpression()); + Record.AddDeclRef(M.getAssociatedDeclaration()); + } +} + +void OMPClauseWriter::VisitOMPFromClause(OMPFromClause *C) { + Record.push_back(C->varlist_size()); + Record.push_back(C->getUniqueDeclarationsNum()); + Record.push_back(C->getTotalComponentListNum()); + Record.push_back(C->getTotalComponentsNum()); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *E : C->varlists()) + Record.AddStmt(E); + for (auto *D : C->all_decls()) + Record.AddDeclRef(D); + for (auto N : C->all_num_lists()) + Record.push_back(N); + for (auto N : C->all_lists_sizes()) + Record.push_back(N); + for (auto &M : C->all_components()) { + Record.AddStmt(M.getAssociatedExpression()); + Record.AddDeclRef(M.getAssociatedDeclaration()); + } +} + +void OMPClauseWriter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) { + Record.push_back(C->varlist_size()); + Record.push_back(C->getUniqueDeclarationsNum()); + Record.push_back(C->getTotalComponentListNum()); + Record.push_back(C->getTotalComponentsNum()); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *E : C->varlists()) + Record.AddStmt(E); + for (auto *VE : C->private_copies()) + Record.AddStmt(VE); + for (auto *VE : C->inits()) + Record.AddStmt(VE); + for (auto *D : C->all_decls()) + Record.AddDeclRef(D); + for (auto N : C->all_num_lists()) + Record.push_back(N); + for (auto N : C->all_lists_sizes()) + Record.push_back(N); + for (auto &M : C->all_components()) { + Record.AddStmt(M.getAssociatedExpression()); + Record.AddDeclRef(M.getAssociatedDeclaration()); + } +} + +void OMPClauseWriter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { + Record.push_back(C->varlist_size()); + Record.push_back(C->getUniqueDeclarationsNum()); + Record.push_back(C->getTotalComponentListNum()); + Record.push_back(C->getTotalComponentsNum()); + Record.AddSourceLocation(C->getLParenLoc()); + for (auto *E : C->varlists()) + Record.AddStmt(E); + for (auto *D : C->all_decls()) + Record.AddDeclRef(D); + for (auto N : C->all_num_lists()) + Record.push_back(N); + for (auto N : C->all_lists_sizes()) + Record.push_back(N); + for (auto &M : C->all_components()) { + Record.AddStmt(M.getAssociatedExpression()); + Record.AddDeclRef(M.getAssociatedDeclaration()); + } +} diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp index 0f67312d0b..17aca06e1a 100644 --- a/lib/Serialization/ASTWriterStmt.cpp +++ b/lib/Serialization/ASTWriterStmt.cpp @@ -1802,485 +1802,6 @@ void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) { Code = serialization::STMT_SEH_LEAVE; } -//===----------------------------------------------------------------------===// -// OpenMP Clauses. -//===----------------------------------------------------------------------===// - -namespace clang { -class OMPClauseWriter : public OMPClauseVisitor { - ASTRecordWriter &Record; -public: - OMPClauseWriter(ASTRecordWriter &Record) : Record(Record) {} -#define OPENMP_CLAUSE(Name, Class) \ - void Visit##Class(Class *S); -#include "clang/Basic/OpenMPKinds.def" - void writeClause(OMPClause *C); - void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C); - void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C); -}; -} - -void OMPClauseWriter::writeClause(OMPClause *C) { - Record.push_back(C->getClauseKind()); - Visit(C); - Record.AddSourceLocation(C->getBeginLoc()); - Record.AddSourceLocation(C->getEndLoc()); -} - -void OMPClauseWriter::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) { - Record.push_back(C->getCaptureRegion()); - Record.AddStmt(C->getPreInitStmt()); -} - -void OMPClauseWriter::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) { - VisitOMPClauseWithPreInit(C); - Record.AddStmt(C->getPostUpdateExpr()); -} - -void OMPClauseWriter::VisitOMPIfClause(OMPIfClause *C) { - VisitOMPClauseWithPreInit(C); - Record.push_back(C->getNameModifier()); - Record.AddSourceLocation(C->getNameModifierLoc()); - Record.AddSourceLocation(C->getColonLoc()); - Record.AddStmt(C->getCondition()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPFinalClause(OMPFinalClause *C) { - Record.AddStmt(C->getCondition()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) { - VisitOMPClauseWithPreInit(C); - Record.AddStmt(C->getNumThreads()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPSafelenClause(OMPSafelenClause *C) { - Record.AddStmt(C->getSafelen()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPSimdlenClause(OMPSimdlenClause *C) { - Record.AddStmt(C->getSimdlen()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPCollapseClause(OMPCollapseClause *C) { - Record.AddStmt(C->getNumForLoops()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) { - Record.push_back(C->getDefaultKind()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getDefaultKindKwLoc()); -} - -void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *C) { - Record.push_back(C->getProcBindKind()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getProcBindKindKwLoc()); -} - -void OMPClauseWriter::VisitOMPScheduleClause(OMPScheduleClause *C) { - VisitOMPClauseWithPreInit(C); - Record.push_back(C->getScheduleKind()); - Record.push_back(C->getFirstScheduleModifier()); - Record.push_back(C->getSecondScheduleModifier()); - Record.AddStmt(C->getChunkSize()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getFirstScheduleModifierLoc()); - Record.AddSourceLocation(C->getSecondScheduleModifierLoc()); - Record.AddSourceLocation(C->getScheduleKindLoc()); - Record.AddSourceLocation(C->getCommaLoc()); -} - -void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *C) { - Record.push_back(C->getLoopNumIterations().size()); - Record.AddStmt(C->getNumForLoops()); - for (Expr *NumIter : C->getLoopNumIterations()) - Record.AddStmt(NumIter); - for (unsigned I = 0, E = C->getLoopNumIterations().size(); I getLoopCunter(I)); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *) {} - -void OMPClauseWriter::VisitOMPUntiedClause(OMPUntiedClause *) {} - -void OMPClauseWriter::VisitOMPMergeableClause(OMPMergeableClause *) {} - -void OMPClauseWriter::VisitOMPReadClause(OMPReadClause *) {} - -void OMPClauseWriter::VisitOMPWriteClause(OMPWriteClause *) {} - -void OMPClauseWriter::VisitOMPUpdateClause(OMPUpdateClause *) {} - -void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {} - -void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {} - -void OMPClauseWriter::VisitOMPThreadsClause(OMPThreadsClause *) {} - -void OMPClauseWriter::VisitOMPSIMDClause(OMPSIMDClause *) {} - -void OMPClauseWriter::VisitOMPNogroupClause(OMPNogroupClause *) {} - -void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) { - Record.push_back(C->varlist_size()); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *VE : C->varlists()) { - Record.AddStmt(VE); - } - for (auto *VE : C->private_copies()) { - Record.AddStmt(VE); - } -} - -void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) { - Record.push_back(C->varlist_size()); - VisitOMPClauseWithPreInit(C); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *VE : C->varlists()) { - Record.AddStmt(VE); - } - for (auto *VE : C->private_copies()) { - Record.AddStmt(VE); - } - for (auto *VE : C->inits()) { - Record.AddStmt(VE); - } -} - -void OMPClauseWriter::VisitOMPLastprivateClause(OMPLastprivateClause *C) { - Record.push_back(C->varlist_size()); - VisitOMPClauseWithPostUpdate(C); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); - for (auto *E : C->private_copies()) - Record.AddStmt(E); - for (auto *E : C->source_exprs()) - Record.AddStmt(E); - for (auto *E : C->destination_exprs()) - Record.AddStmt(E); - for (auto *E : C->assignment_ops()) - Record.AddStmt(E); -} - -void OMPClauseWriter::VisitOMPSharedClause(OMPSharedClause *C) { - Record.push_back(C->varlist_size()); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); -} - -void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *C) { - Record.push_back(C->varlist_size()); - VisitOMPClauseWithPostUpdate(C); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getColonLoc()); - Record.AddNestedNameSpecifierLoc(C->getQualifierLoc()); - Record.AddDeclarationNameInfo(C->getNameInfo()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); - for (auto *VE : C->privates()) - Record.AddStmt(VE); - for (auto *E : C->lhs_exprs()) - Record.AddStmt(E); - for (auto *E : C->rhs_exprs()) - Record.AddStmt(E); - for (auto *E : C->reduction_ops()) - Record.AddStmt(E); -} - -void OMPClauseWriter::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) { - Record.push_back(C->varlist_size()); - VisitOMPClauseWithPostUpdate(C); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getColonLoc()); - Record.AddNestedNameSpecifierLoc(C->getQualifierLoc()); - Record.AddDeclarationNameInfo(C->getNameInfo()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); - for (auto *VE : C->privates()) - Record.AddStmt(VE); - for (auto *E : C->lhs_exprs()) - Record.AddStmt(E); - for (auto *E : C->rhs_exprs()) - Record.AddStmt(E); - for (auto *E : C->reduction_ops()) - Record.AddStmt(E); -} - -void OMPClauseWriter::VisitOMPInReductionClause(OMPInReductionClause *C) { - Record.push_back(C->varlist_size()); - VisitOMPClauseWithPostUpdate(C); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getColonLoc()); - Record.AddNestedNameSpecifierLoc(C->getQualifierLoc()); - Record.AddDeclarationNameInfo(C->getNameInfo()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); - for (auto *VE : C->privates()) - Record.AddStmt(VE); - for (auto *E : C->lhs_exprs()) - Record.AddStmt(E); - for (auto *E : C->rhs_exprs()) - Record.AddStmt(E); - for (auto *E : C->reduction_ops()) - Record.AddStmt(E); - for (auto *E : C->taskgroup_descriptors()) - Record.AddStmt(E); -} - -void OMPClauseWriter::VisitOMPLinearClause(OMPLinearClause *C) { - Record.push_back(C->varlist_size()); - VisitOMPClauseWithPostUpdate(C); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getColonLoc()); - Record.push_back(C->getModifier()); - Record.AddSourceLocation(C->getModifierLoc()); - for (auto *VE : C->varlists()) { - Record.AddStmt(VE); - } - for (auto *VE : C->privates()) { - Record.AddStmt(VE); - } - for (auto *VE : C->inits()) { - Record.AddStmt(VE); - } - for (auto *VE : C->updates()) { - Record.AddStmt(VE); - } - for (auto *VE : C->finals()) { - Record.AddStmt(VE); - } - Record.AddStmt(C->getStep()); - Record.AddStmt(C->getCalcStep()); -} - -void OMPClauseWriter::VisitOMPAlignedClause(OMPAlignedClause *C) { - Record.push_back(C->varlist_size()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getColonLoc()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); - Record.AddStmt(C->getAlignment()); -} - -void OMPClauseWriter::VisitOMPCopyinClause(OMPCopyinClause *C) { - Record.push_back(C->varlist_size()); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); - for (auto *E : C->source_exprs()) - Record.AddStmt(E); - for (auto *E : C->destination_exprs()) - Record.AddStmt(E); - for (auto *E : C->assignment_ops()) - Record.AddStmt(E); -} - -void OMPClauseWriter::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) { - Record.push_back(C->varlist_size()); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); - for (auto *E : C->source_exprs()) - Record.AddStmt(E); - for (auto *E : C->destination_exprs()) - Record.AddStmt(E); - for (auto *E : C->assignment_ops()) - Record.AddStmt(E); -} - -void OMPClauseWriter::VisitOMPFlushClause(OMPFlushClause *C) { - Record.push_back(C->varlist_size()); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); -} - -void OMPClauseWriter::VisitOMPDependClause(OMPDependClause *C) { - Record.push_back(C->varlist_size()); - Record.push_back(C->getNumLoops()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.push_back(C->getDependencyKind()); - Record.AddSourceLocation(C->getDependencyLoc()); - Record.AddSourceLocation(C->getColonLoc()); - for (auto *VE : C->varlists()) - Record.AddStmt(VE); - for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I) - Record.AddStmt(C->getLoopData(I)); -} - -void OMPClauseWriter::VisitOMPDeviceClause(OMPDeviceClause *C) { - VisitOMPClauseWithPreInit(C); - Record.AddStmt(C->getDevice()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *C) { - Record.push_back(C->varlist_size()); - Record.push_back(C->getUniqueDeclarationsNum()); - Record.push_back(C->getTotalComponentListNum()); - Record.push_back(C->getTotalComponentsNum()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.push_back(C->getMapTypeModifier()); - Record.push_back(C->getMapType()); - Record.AddSourceLocation(C->getMapLoc()); - Record.AddSourceLocation(C->getColonLoc()); - for (auto *E : C->varlists()) - Record.AddStmt(E); - for (auto *D : C->all_decls()) - Record.AddDeclRef(D); - for (auto N : C->all_num_lists()) - Record.push_back(N); - for (auto N : C->all_lists_sizes()) - Record.push_back(N); - for (auto &M : C->all_components()) { - Record.AddStmt(M.getAssociatedExpression()); - Record.AddDeclRef(M.getAssociatedDeclaration()); - } -} - -void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) { - VisitOMPClauseWithPreInit(C); - Record.AddStmt(C->getNumTeams()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) { - VisitOMPClauseWithPreInit(C); - Record.AddStmt(C->getThreadLimit()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPPriorityClause(OMPPriorityClause *C) { - Record.AddStmt(C->getPriority()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) { - Record.AddStmt(C->getGrainsize()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPNumTasksClause(OMPNumTasksClause *C) { - Record.AddStmt(C->getNumTasks()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPHintClause(OMPHintClause *C) { - Record.AddStmt(C->getHint()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) { - VisitOMPClauseWithPreInit(C); - Record.push_back(C->getDistScheduleKind()); - Record.AddStmt(C->getChunkSize()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getDistScheduleKindLoc()); - Record.AddSourceLocation(C->getCommaLoc()); -} - -void OMPClauseWriter::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) { - Record.push_back(C->getDefaultmapKind()); - Record.push_back(C->getDefaultmapModifier()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getDefaultmapModifierLoc()); - Record.AddSourceLocation(C->getDefaultmapKindLoc()); -} - -void OMPClauseWriter::VisitOMPToClause(OMPToClause *C) { - Record.push_back(C->varlist_size()); - Record.push_back(C->getUniqueDeclarationsNum()); - Record.push_back(C->getTotalComponentListNum()); - Record.push_back(C->getTotalComponentsNum()); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *E : C->varlists()) - Record.AddStmt(E); - for (auto *D : C->all_decls()) - Record.AddDeclRef(D); - for (auto N : C->all_num_lists()) - Record.push_back(N); - for (auto N : C->all_lists_sizes()) - Record.push_back(N); - for (auto &M : C->all_components()) { - Record.AddStmt(M.getAssociatedExpression()); - Record.AddDeclRef(M.getAssociatedDeclaration()); - } -} - -void OMPClauseWriter::VisitOMPFromClause(OMPFromClause *C) { - Record.push_back(C->varlist_size()); - Record.push_back(C->getUniqueDeclarationsNum()); - Record.push_back(C->getTotalComponentListNum()); - Record.push_back(C->getTotalComponentsNum()); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *E : C->varlists()) - Record.AddStmt(E); - for (auto *D : C->all_decls()) - Record.AddDeclRef(D); - for (auto N : C->all_num_lists()) - Record.push_back(N); - for (auto N : C->all_lists_sizes()) - Record.push_back(N); - for (auto &M : C->all_components()) { - Record.AddStmt(M.getAssociatedExpression()); - Record.AddDeclRef(M.getAssociatedDeclaration()); - } -} - -void OMPClauseWriter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) { - Record.push_back(C->varlist_size()); - Record.push_back(C->getUniqueDeclarationsNum()); - Record.push_back(C->getTotalComponentListNum()); - Record.push_back(C->getTotalComponentsNum()); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *E : C->varlists()) - Record.AddStmt(E); - for (auto *VE : C->private_copies()) - Record.AddStmt(VE); - for (auto *VE : C->inits()) - Record.AddStmt(VE); - for (auto *D : C->all_decls()) - Record.AddDeclRef(D); - for (auto N : C->all_num_lists()) - Record.push_back(N); - for (auto N : C->all_lists_sizes()) - Record.push_back(N); - for (auto &M : C->all_components()) { - Record.AddStmt(M.getAssociatedExpression()); - Record.AddDeclRef(M.getAssociatedDeclaration()); - } -} - -void OMPClauseWriter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { - Record.push_back(C->varlist_size()); - Record.push_back(C->getUniqueDeclarationsNum()); - Record.push_back(C->getTotalComponentListNum()); - Record.push_back(C->getTotalComponentsNum()); - Record.AddSourceLocation(C->getLParenLoc()); - for (auto *E : C->varlists()) - Record.AddStmt(E); - for (auto *D : C->all_decls()) - Record.AddDeclRef(D); - for (auto N : C->all_num_lists()) - Record.push_back(N); - for (auto N : C->all_lists_sizes()) - Record.push_back(N); - for (auto &M : C->all_components()) { - Record.AddStmt(M.getAssociatedExpression()); - Record.AddDeclRef(M.getAssociatedDeclaration()); - } -} - //===----------------------------------------------------------------------===// // OpenMP Directives. //===----------------------------------------------------------------------===// -- 2.40.0