-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[feat] Clang format detect when using struct XYZ instead of XYZ (typedef) #91063
Comments
@llvm/issue-subscribers-clang-tidy Author: Ilan Schemoul (ilan-schemoul)
Hey,
It would be awesome to have an option (the name could be UseTypedefInsteafOfFullStructName) so when we have this
```c
struct abc{};
typedef struct abc a;
int main() {
struct abc b;
}
```
`struct abc b;` gets replaced by "a b;"
|
Clang-format is not supposed to modify code. |
Oh okay I thought as typedef was to define an alias clang-format was okay with that but I understand that you don't want a formatter to modify code. |
struct abc{}; |
You can specify the preference order and for example choose that if there's multiples one you always pick the first. |
"always pick the first" leads to a semantic error. |
Why ? |
In my opinion, the issue can be closed. |
Well then it's not a problem anymore ? If one of a or x definition is not struct abc then we don't pick it when we format ? I am missing the point ? You're talking about a very specific edge case "what if someone would give two typedef to the same struct and then modify a single one of them" and even then I don't see your point still. Well if someone modify one typedef they known what they're doing I don't see the problem. |
Hey,
It would be awesome to have an option (the name could be
UseTypedefInsteafOfFullStructName
) so when we have thisstruct abc b;
gets replaced bya b;
The text was updated successfully, but these errors were encountered: