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

Allow loop annotations at the top of loop body #8481

Open
hanno-becker opened this issue Oct 16, 2024 · 3 comments
Open

Allow loop annotations at the top of loop body #8481

hanno-becker opened this issue Oct 16, 2024 · 3 comments

Comments

@hanno-becker
Copy link

Issue: CBMC currently requires loop annotations to be placed between for(...) and {...}. This is inconvenient for code that's subject to automatic formatting. For example, there is no option (I know of) for clang-format that would lead to a reasonable formatting of annotations. One can work around it by adding // clang-format: on/off annotations, but that adds to the visual load of the annotation themselves, and makes the code overall harder to read.

Ask: For CBMC to additionally support loop annotations be placed at the top of the loop body.

Continuing the example of clang-format, one could then mark the CBMC macros as statements, and they would be formatted in-line with the rest of the loop body.

@hanno-becker
Copy link
Author

Ask 2: To additionally support function contracts be placed atop or below (either will be OK) function declarations in .h files.

(Reason is the same)

@tautschnig
Copy link
Collaborator

Ask 2: To additionally support function contracts be placed atop or below (either will be OK) function declarations in .h files.

(Reason is the same)

I must be misunderstanding as placing them below is exactly what we do right now? Could you please clarify?

@hanno-becker
Copy link
Author

Here's an example of what we do at the moment: https://github.com/pq-code-package/mlkem-c-aarch64/blob/main/mlkem/reduce.h#L12

Are you saying we could move everything past the ; and it would be fine?

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