@@ -85,11 +85,13 @@ llvm::Optional<std::string> getSystemHeaderForDecl(clang::Decl *D) {
85
85
}
86
86
87
87
bool FindTargetCodeVisitor::TraverseDecl (clang::Decl *D) {
88
- if (auto *FD = llvm::dyn_cast<clang::FunctionDecl>(D)) {
88
+ bool PushedDecl = false ;
89
+ if (auto *FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(D)) {
89
90
LastVisitedFuncDecl.push (FD);
91
+ PushedDecl = true ;
90
92
}
91
93
bool ret = clang::RecursiveASTVisitor<FindTargetCodeVisitor>::TraverseDecl (D);
92
- if (auto *FD = llvm::dyn_cast<clang::FunctionDecl>(D) ) {
94
+ if (PushedDecl ) {
93
95
LastVisitedFuncDecl.pop ();
94
96
}
95
97
return ret;
@@ -134,9 +136,10 @@ bool FindTargetCodeVisitor::VisitStmt(clang::Stmt *S) {
134
136
class CollectOMPClauseParamsVarsVisitor
135
137
: public clang::RecursiveASTVisitor<CollectOMPClauseParamsVarsVisitor> {
136
138
std::shared_ptr<TargetCodeRegion> TCR;
139
+
137
140
public:
138
141
CollectOMPClauseParamsVarsVisitor (std::shared_ptr<TargetCodeRegion> &TCR)
139
- : TCR(TCR) {};
142
+ : TCR(TCR){};
140
143
141
144
bool VisitStmt (clang::Stmt *S) {
142
145
if (auto *DRE = llvm::dyn_cast<clang::DeclRefExpr>(S)) {
@@ -151,15 +154,16 @@ class CollectOMPClauseParamsVarsVisitor
151
154
class CollectOMPClauseParamsVisitor
152
155
: public clang::RecursiveASTVisitor<CollectOMPClauseParamsVisitor> {
153
156
154
- CollectOMPClauseParamsVarsVisitor VarsVisitor;
157
+ CollectOMPClauseParamsVarsVisitor VarsVisitor;
155
158
bool InExplicitCast;
159
+
156
160
public:
157
161
CollectOMPClauseParamsVisitor (std::shared_ptr<TargetCodeRegion> &TCR)
158
- : VarsVisitor(TCR), InExplicitCast(false ) {};
162
+ : VarsVisitor(TCR), InExplicitCast(false ){};
159
163
bool VisitStmt (clang::Stmt *S) {
160
164
// This relies on the captured statement being the last child
161
165
if (llvm::isa<clang::CapturedStmt>(S)) {
162
- return false ;
166
+ return false ;
163
167
}
164
168
165
169
if (llvm::isa<clang::ImplicitCastExpr>(S)) {
@@ -197,7 +201,8 @@ bool FindTargetCodeVisitor::processTargetRegion(
197
201
// if the target region cannot be added we dont want to parse its args
198
202
if (TargetCodeInfo.addCodeFragment (TCR)) {
199
203
200
- FindArraySectionVisitor (TCR->CapturedLowerBounds ).TraverseStmt (TargetDirective);
204
+ FindArraySectionVisitor (TCR->CapturedLowerBounds )
205
+ .TraverseStmt (TargetDirective);
201
206
202
207
for (auto C : TargetDirective->clauses ()) {
203
208
TCR->addOMPClause (C);
@@ -283,7 +288,6 @@ bool FindLoopStmtVisitor::VisitStmt(clang::Stmt *S) {
283
288
return true ;
284
289
}
285
290
286
-
287
291
bool FindDeclRefExprVisitor::VisitStmt (clang::Stmt *S) {
288
292
if (auto DRE = llvm::dyn_cast<clang::DeclRefExpr>(S)) {
289
293
if (auto DD = llvm::dyn_cast<clang::DeclaratorDecl>(DRE->getDecl ())) {
@@ -407,7 +411,8 @@ bool FindPrivateVariablesVisitor::VisitExpr(clang::Expr *E) {
407
411
408
412
// If the variable is declared outside of the target region it may be a
409
413
// private variable
410
- if (SM.isBeforeInTranslationUnit (VD->getLocation (), RegionTopSourceLocation)) {
414
+ if (SM.isBeforeInTranslationUnit (VD->getLocation (),
415
+ RegionTopSourceLocation)) {
411
416
// Add the Variable to our set
412
417
VarSet.insert (VD);
413
418
}
0 commit comments