Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-format] Correctly format goto labels followed by blocks
There doesn't seem to be an issue on GitHub. But previously, a space would be inserted before the goto colon in the code below. switch (x) { case 0: goto_0: { action(); break; } } Previously, the colon following a goto label would be annotated as `TT_InheritanceColon`. A goto label followed by an opening brace wasn't recognized. It is easy to add another line to have `spaceRequiredBefore` function recognize the case, but I believed it is more proper to avoid doing the same thing in `UnwrappedLineParser` and `TokenAnnotator`. So now the label colons would be labeled in `UnwrappedLineParser`, and `spaceRequiredBefore` would rely on that. Previously we had the type `TT_GotoLabelColon` intended for both goto labels and case labels. But since handling of goto labels and case labels differ somewhat, I split it into separate types for goto and case labels. This patch doesn't change the behavior for case labels. I added the lines annotating case labels because they would previously be mistakenly annotated as `TT_InheritanceColon` just like goto labels. And since I added the annotations, the checks for the `case` and `default` keywords in `spaceRequiredBefore` are not necessary anymore. Reviewed By: MyDeveloperDay Differential Revision: https://reviews.llvm.org/D148484
- Loading branch information
Showing
5 changed files
with
79 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters