Skip to content
New issue

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

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

Already on GitHub? # to your account

C++ header files should have // clang on added *after* the final comment block #1201

Closed
KeyWorksRW opened this issue Aug 30, 2023 · 0 comments · Fixed by #1332
Closed

C++ header files should have // clang on added *after* the final comment block #1201

KeyWorksRW opened this issue Aug 30, 2023 · 0 comments · Fixed by #1332
Labels
design change Underlying design may need changing

Comments

@KeyWorksRW
Copy link
Owner

Description:

Currently in all generated header files, the // clang on is written in column zero just before the closing comment line (also written in column zero). As long as the class declaration is closed with a } then calling clang-format on this file will leave the generated code untouched. However, if the user specifies that they don't want the closing brace, then both the // clang on and the following line are indented. That results in a difference being generated every time the file gets generated and the user modifies and reformats it.

I think a better approach would be to change the generation of // clang on. If the header file has no user-modifications, the comment line should be added after the closing block, with indentation chosen based on whether or not a closing brace is being generated. If there is user-specified code, then don't add // clang on which lets the user choose whether or when to turn formatting back on.

Effectively, once the // clang on gets written the first time the file is created, that line gets treated as if the user created it.

@KeyWorksRW KeyWorksRW added the design change Underlying design may need changing label Aug 30, 2023
Randalphwa added a commit that referenced this issue Sep 4, 2023
This is due to the issue in #1201
Randalphwa added a commit that referenced this issue Dec 2, 2023
Because of this issue, any time this file is generated, it has to be manually
reformatted with clang-format.
Randalphwa added a commit that referenced this issue Dec 11, 2023
Previously, these files had to be regenerated every time they were regenerated.
This fixes that, allowing us to format it the way clang-format wants and leave
it that way.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
design change Underlying design may need changing
Projects
None yet
1 participant