Skip to content

Commit 477b48e

Browse files
committed
[OpenACC][NFC] Implement RecursiveASTVisitor for clauses
Clauses that have sub expressions are storing them in 'children', so make sure we visit these properly.
1 parent a0e6f83 commit 477b48e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "clang/AST/ExprOpenMP.h"
3131
#include "clang/AST/LambdaCapture.h"
3232
#include "clang/AST/NestedNameSpecifier.h"
33+
#include "clang/AST/OpenACCClause.h"
3334
#include "clang/AST/OpenMPClause.h"
3435
#include "clang/AST/Stmt.h"
3536
#include "clang/AST/StmtCXX.h"
@@ -510,6 +511,7 @@ template <typename Derived> class RecursiveASTVisitor {
510511
bool
511512
TraverseOpenACCAssociatedStmtConstruct(OpenACCAssociatedStmtConstruct *S);
512513
bool VisitOpenACCClauseList(ArrayRef<const OpenACCClause *>);
514+
bool VisitOpenACCClause(const OpenACCClause *);
513515
};
514516

515517
template <typename Derived>
@@ -3967,9 +3969,26 @@ bool RecursiveASTVisitor<Derived>::TraverseOpenACCAssociatedStmtConstruct(
39673969
return true;
39683970
}
39693971

3972+
template <typename Derived>
3973+
bool RecursiveASTVisitor<Derived>::VisitOpenACCClause(const OpenACCClause *C) {
3974+
for (const Stmt *Child : C->children())
3975+
TRY_TO(TraverseStmt(const_cast<Stmt *>(Child)));
3976+
return true;
3977+
}
3978+
39703979
template <typename Derived>
39713980
bool RecursiveASTVisitor<Derived>::VisitOpenACCClauseList(
3972-
ArrayRef<const OpenACCClause *>) {
3981+
ArrayRef<const OpenACCClause *> Clauses) {
3982+
3983+
for (const auto *C : Clauses)
3984+
TRY_TO(VisitOpenACCClause(C));
3985+
// if (const auto *WithCond = dyn_cast<OopenACCClauseWithCondition>(C);
3986+
// WithCond && WIthCond->hasConditionExpr()) {
3987+
// TRY_TO(TraverseStmt(WithCond->getConditionExpr());
3988+
// } else if (const auto *
3989+
// }
3990+
// OpenACCClauseWithCondition::getConditionExpr/hasConditionExpr
3991+
//OpenACCClauseWithExprs::children (might be null?)
39733992
// TODO OpenACC: When we have Clauses with expressions, we should visit them
39743993
// here.
39753994
return true;

0 commit comments

Comments
 (0)