diff --git a/ClavaAst/src/pt/up/fe/specs/clava/ClavaNodes.java b/ClavaAst/src/pt/up/fe/specs/clava/ClavaNodes.java index ed8bcbbb7..9e65b719d 100644 --- a/ClavaAst/src/pt/up/fe/specs/clava/ClavaNodes.java +++ b/ClavaAst/src/pt/up/fe/specs/clava/ClavaNodes.java @@ -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; @@ -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; + } }