-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
clang-format removes space between 'override' and curly brace when there's a trailing semicolon #57305
Comments
@llvm/issue-subscribers-clang-format |
Issue is around here: llvm-project/clang/lib/Format/UnwrappedLineParser.cpp Lines 711 to 713 in 8856137
It is infact doing what the comment says, but I guess it needs extra context that it's parsing a declaration FWIW, all that's needed to reproduce this is Also, a trailing annotation such as |
Oh! definitely related void a() {}
void a() {}
void a() { return a; }
void a() { return a; }
void a() override {}
void a() override{}; |
Perhaps we need another pass, after the assignment of TT_FunctionDeclarationName, where we go back over and set the TT_FunctionLBrace, and find the unnecessary I think this could fix the spacing and mark the ; optional so they get removed later @owenca any thoughts? TokenAnnotator Annotator(Style, Keywords);
Annotator.annotate(Line);
Annotator.calculateFormattingInformation(Line);
Annotator.enusreFunctionLBrace();
^^^^^ |
More test cases void a() {}
void a(){};
void a() { return a; }
void a() { return a; }
void a() override {}
void a() override{};
void a() noexcept {}
void a() noexcept(false){};
auto a() -> void {}
auto a() -> void{}; |
It might work, but I don't think it's worth fixing, especially at the cost of adding another pass. BTW I succeeded in fixing all of the above test cases (except |
Also fixed some existing test cases. Fixed llvm#57305. Fixed llvm#58251.
Also fixed some existing test cases. Fixed llvm#57305. Fixed llvm#58251.
Also fixed some existing test cases. Fixed llvm#57305. Fixed llvm#58251.
Consider:
Note the missing space between
override
and{
.This only seems to happen when there's a trailing semicolon --- which is of course unnecessary and
-Wextra-semi
warns about it --- but it would be nice if clang-format could handle it.The text was updated successfully, but these errors were encountered: