Skip to content

Commit

Permalink
[ClavaAst] Adds ClavaNodes.acceptsPragmas() (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaobispo committed Oct 22, 2021
1 parent 33559fc commit dbecaf6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ClavaAst/src/pt/up/fe/specs/clava/ClavaNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import pt.up.fe.specs.clava.ast.expr.enums.BinaryOperatorKind;
import pt.up.fe.specs.clava.ast.expr.enums.ExprUse;
import pt.up.fe.specs.clava.ast.expr.enums.UnaryOperatorKind;
import pt.up.fe.specs.clava.ast.extra.TranslationUnit;
import pt.up.fe.specs.clava.ast.pragma.Pragma;
import pt.up.fe.specs.clava.ast.stmt.CXXForRangeStmt;
import pt.up.fe.specs.clava.ast.stmt.CompoundStmt;
Expand Down Expand Up @@ -738,4 +739,24 @@ public static ClavaNode getFirstNodeOfTargetRegion(ClavaNode base, ClavaNode new
// Finished loop without returning, first not is a text element
return currentBase;
}

/**
* A node accepts pragmas if its parent can have pragmas (e.g. CompoundStmt, TranslationUnit)
*
* @param node
* @return true if the node accepts pragmas, false otherwise
*/
public static boolean acceptsPragmas(ClavaNode node) {
var parent = node.getParent();

if (parent instanceof CompoundStmt) {
return true;
}

if (parent instanceof TranslationUnit) {
return true;
}

return false;
}
}

0 comments on commit dbecaf6

Please sign in to comment.