Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clava AST and Lang. Spec: Loop header types inconsistent with Clang #71

Open
joaonmatos opened this issue Jun 6, 2022 · 2 comments
Open

Comments

@joaonmatos
Copy link
Contributor

joaonmatos commented Jun 6, 2022

In the Clava AST and Language Specification, the header children of loop statements (init, condition, and step), are being parsed and stored as a statement. See pt.up.fe.specs.clava.ast.stmt.{ForStmt, WhileStmt, DoStmt}, and lines 303 through 310 of ClavaWeaver's artifacts.xml. However, the clang ast, as specified in the following cases:

(including conditional statements for completeness)

Always defines these kind of children as expression. Therefore, it is redundant to have them as a statement, as they will always be an ExprStmt, and the expression must be extracted for most useful analyses.

It would make sense to adjust this API into returning expressions. Client code, if possible, should be adjusted as necessary.

@joaobispo
Copy link
Member

This is a tricky situation. There are some cases where it is advantageous to see the elements in the loop header as statements, others as expressions.

Additionally, expressions in Clava are a separate hierarchy from statements, but it Clang, expressions ARE statements (Expr extends Stmt), so it is not strictly against Clang specification to have an ExprStmt as a loop header element.

I think this needs further evaluation and will leave it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants