-
Notifications
You must be signed in to change notification settings - Fork 3
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
Incorrect formatting for class and struct members #19
Comments
To be precise, the expected style from the guidelines is defined by this example (note: this does not look correct on github because they don't use 4 columns per tab character. refer to the Haiku website or a properly configured editor for the correct look):
The basic idea is: indented 1 tab: qualifiers (volatile, virtual, static) This normally allows to keep all types nicely aligned (unless you have something complicated like a "static volatile") and generally keep all function and field names also aligned (unless you have a complicated return type for one of them) In some cases we move the function and field names to a further tab stop (9 or 10) to keep things aligned even when there are long return types. Sometimes we move them back to the left when return types are short, but function or field names are very long. It's possible we will need to decide on something stricter for clang-format because the current style may be hard to write code for. But at least we should make sure that we keep using tabs and try to keep things aligned. |
This is not something that should be handled by clang-format/haiku-format. You may have to use clang-format off if you want to keep the indentations. |
We use this style everywhere in Haiku class definitions, so if we just turn clang-format off in all these places, it makes the tool a bit useless. clang-format already does something similar with aligning declarations, why couldn't it do it for field and method definitions? |
To keep clang-format light and make it run reasonably fast, its creators only used the lexer of clang cfe. Without the AST, clang-format relies heavily on heaustics when guessing the semantics of the tokens. I don't think Haiku's alignment requirements/preferences within class declarations can be easily handled by clang-format. |
The code for this issue can be found here : |
Can you create a PR at https://github.com/owenca/llvm-project/tree/haiku-format? Please also include the test case(s) you used. Thanks! |
@owenca could you rename this ticket to 'Incorrect formatting for class and struct members'? |
I've just tried it on a snippet from the example above: Not only is the alignment off and Even worse, it crashed on a format test:
|
Output of Haiku-format is converting tabs into spaces :
whereas the expected output is :
The text was updated successfully, but these errors were encountered: