@@ -593,6 +593,81 @@ class OpenACCWaitConstruct final
593593 }
594594};
595595
596+ class OpenACCCacheConstruct final
597+ : public OpenACCConstructStmt,
598+ private llvm::TrailingObjects<OpenACCCacheConstruct, Expr *> {
599+ friend TrailingObjects;
600+ friend class ASTStmtWriter ;
601+ friend class ASTStmtReader ;
602+ // Locations of the left and right parens of the 'var-list'
603+ // expression-list.
604+ SourceRange ParensLoc;
605+ SourceLocation ReadOnlyLoc;
606+
607+ unsigned NumVars = 0 ;
608+
609+ OpenACCCacheConstruct (unsigned NumVars)
610+ : OpenACCConstructStmt(OpenACCCacheConstructClass,
611+ OpenACCDirectiveKind::Cache, SourceLocation{},
612+ SourceLocation{}, SourceLocation{}),
613+ NumVars (NumVars) {
614+ std::uninitialized_value_construct (getVarListPtr (),
615+ getVarListPtr () + NumVars);
616+ }
617+ OpenACCCacheConstruct (SourceLocation Start, SourceLocation DirectiveLoc,
618+ SourceLocation LParenLoc, SourceLocation ReadOnlyLoc,
619+ ArrayRef<Expr *> VarList, SourceLocation RParenLoc,
620+ SourceLocation End)
621+ : OpenACCConstructStmt(OpenACCCacheConstructClass,
622+ OpenACCDirectiveKind::Cache, Start, DirectiveLoc,
623+ End),
624+ ParensLoc (LParenLoc, RParenLoc), ReadOnlyLoc(ReadOnlyLoc),
625+ NumVars(VarList.size()) {
626+
627+ std::uninitialized_copy (VarList.begin (), VarList.end (), getVarListPtr ());
628+ }
629+
630+ Expr **getVarListPtr () const {
631+ return const_cast <Expr **>(getTrailingObjects<Expr *>());
632+ }
633+
634+ public:
635+ llvm::ArrayRef<Expr *> getVarList () const {
636+ return llvm::ArrayRef<Expr *>(getVarListPtr (), NumVars);
637+ }
638+
639+ llvm::ArrayRef<Expr *> getVarList () {
640+ return llvm::ArrayRef<Expr *>(getVarListPtr (), NumVars);
641+ }
642+
643+ static bool classof (const Stmt *T) {
644+ return T->getStmtClass () == OpenACCCacheConstructClass;
645+ }
646+
647+ static OpenACCCacheConstruct *CreateEmpty (const ASTContext &C,
648+ unsigned NumVars);
649+ static OpenACCCacheConstruct *
650+ Create (const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
651+ SourceLocation LParenLoc, SourceLocation ReadOnlyLoc,
652+ ArrayRef<Expr *> VarList, SourceLocation RParenLoc,
653+ SourceLocation End);
654+
655+ SourceLocation getLParenLoc () const { return ParensLoc.getBegin (); }
656+ SourceLocation getRParenLoc () const { return ParensLoc.getEnd (); }
657+ bool hasReadOnly () const { return !ReadOnlyLoc.isInvalid (); }
658+ SourceLocation getReadOnlyLoc () const { return ReadOnlyLoc; }
659+
660+ child_range children () {
661+ Stmt **Begin = reinterpret_cast <Stmt **>(getVarListPtr ());
662+ return child_range (Begin, Begin + NumVars);
663+ }
664+
665+ const_child_range children () const {
666+ Stmt *const *Begin = reinterpret_cast <Stmt *const *>(getVarListPtr ());
667+ return const_child_range (Begin, Begin + NumVars);
668+ }
669+ };
670+
596671// This class represents an 'init' construct, which has just a clause list.
597672class OpenACCInitConstruct final
598673 : public OpenACCConstructStmt,
0 commit comments