@@ -28,44 +28,15 @@ OpenACCComputeConstruct::CreateEmpty(const ASTContext &C, unsigned NumClauses) {
2828OpenACCComputeConstruct *OpenACCComputeConstruct::Create (
2929 const ASTContext &C, OpenACCDirectiveKind K, SourceLocation BeginLoc,
3030 SourceLocation DirLoc, SourceLocation EndLoc,
31- ArrayRef<const OpenACCClause *> Clauses, Stmt *StructuredBlock,
32- ArrayRef<OpenACCLoopConstruct *> AssociatedLoopConstructs) {
31+ ArrayRef<const OpenACCClause *> Clauses, Stmt *StructuredBlock) {
3332 void *Mem = C.Allocate (
3433 OpenACCComputeConstruct::totalSizeToAlloc<const OpenACCClause *>(
3534 Clauses.size ()));
3635 auto *Inst = new (Mem) OpenACCComputeConstruct (K, BeginLoc, DirLoc, EndLoc,
3736 Clauses, StructuredBlock);
38-
39- llvm::for_each (AssociatedLoopConstructs, [&](OpenACCLoopConstruct *C) {
40- C->setParentComputeConstruct (Inst);
41- });
42-
4337 return Inst;
4438}
4539
46- void OpenACCComputeConstruct::findAndSetChildLoops () {
47- struct LoopConstructFinder : RecursiveASTVisitor<LoopConstructFinder> {
48- OpenACCComputeConstruct *Construct = nullptr ;
49-
50- LoopConstructFinder (OpenACCComputeConstruct *Construct)
51- : Construct(Construct) {}
52-
53- bool TraverseOpenACCComputeConstruct (OpenACCComputeConstruct *C) {
54- // Stop searching if we find a compute construct.
55- return true ;
56- }
57- bool TraverseOpenACCLoopConstruct (OpenACCLoopConstruct *C) {
58- // Stop searching if we find a loop construct, after taking ownership of
59- // it.
60- C->setParentComputeConstruct (Construct);
61- return true ;
62- }
63- };
64-
65- LoopConstructFinder f (this );
66- f.TraverseStmt (getAssociatedStmt ());
67- }
68-
6940OpenACCLoopConstruct::OpenACCLoopConstruct (unsigned NumClauses)
7041 : OpenACCAssociatedStmtConstruct(
7142 OpenACCLoopConstructClass, OpenACCDirectiveKind::Loop,
@@ -79,11 +50,13 @@ OpenACCLoopConstruct::OpenACCLoopConstruct(unsigned NumClauses)
7950}
8051
8152OpenACCLoopConstruct::OpenACCLoopConstruct (
82- SourceLocation Start, SourceLocation DirLoc, SourceLocation End,
53+ OpenACCDirectiveKind ParentKind, SourceLocation Start,
54+ SourceLocation DirLoc, SourceLocation End,
8355 ArrayRef<const OpenACCClause *> Clauses, Stmt *Loop)
8456 : OpenACCAssociatedStmtConstruct(OpenACCLoopConstructClass,
8557 OpenACCDirectiveKind::Loop, Start, DirLoc,
86- End, Loop) {
58+ End, Loop),
59+ ParentComputeConstructKind(ParentKind) {
8760 // accept 'nullptr' for the loop. This is diagnosed somewhere, but this gives
8861 // us some level of AST fidelity in the error case.
8962 assert ((Loop == nullptr || isa<ForStmt, CXXForRangeStmt>(Loop)) &&
@@ -96,12 +69,6 @@ OpenACCLoopConstruct::OpenACCLoopConstruct(
9669 Clauses.size ()));
9770}
9871
99- void OpenACCLoopConstruct::setLoop (Stmt *Loop) {
100- assert ((isa<ForStmt, CXXForRangeStmt>(Loop)) &&
101- " Associated Loop not a for loop?" );
102- setAssociatedStmt (Loop);
103- }
104-
10572OpenACCLoopConstruct *OpenACCLoopConstruct::CreateEmpty (const ASTContext &C,
10673 unsigned NumClauses) {
10774 void *Mem =
@@ -111,15 +78,14 @@ OpenACCLoopConstruct *OpenACCLoopConstruct::CreateEmpty(const ASTContext &C,
11178 return Inst;
11279}
11380
114- OpenACCLoopConstruct *
115- OpenACCLoopConstruct::Create (const ASTContext &C, SourceLocation BeginLoc,
116- SourceLocation DirLoc, SourceLocation EndLoc,
117- ArrayRef<const OpenACCClause *> Clauses,
118- Stmt *Loop) {
81+ OpenACCLoopConstruct *OpenACCLoopConstruct::Create (
82+ const ASTContext &C, OpenACCDirectiveKind ParentKind,
83+ SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc,
84+ ArrayRef<const OpenACCClause *> Clauses, Stmt *Loop) {
11985 void *Mem =
12086 C.Allocate (OpenACCLoopConstruct::totalSizeToAlloc<const OpenACCClause *>(
12187 Clauses.size ()));
122- auto *Inst =
123- new (Mem) OpenACCLoopConstruct (BeginLoc, DirLoc, EndLoc, Clauses, Loop);
88+ auto *Inst = new (Mem)
89+ OpenACCLoopConstruct (ParentKind, BeginLoc, DirLoc, EndLoc, Clauses, Loop);
12490 return Inst;
12591}
0 commit comments