[all-commits] [llvm/llvm-project] 82a90c: [clang-format] Correctly format goto labels follow...
eywdck2l via All-commits
all-commits at lists.llvm.org
Sun Apr 30 15:35:33 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 82a90caa88fdc632ea2c8495ea3237065272a3a0
https://github.com/llvm/llvm-project/commit/82a90caa88fdc632ea2c8495ea3237065272a3a0
Author: sstwcw <f0gukp2nk at protonmail.com>
Date: 2023-04-30 (Sun, 30 Apr 2023)
Changed paths:
M clang/lib/Format/FormatToken.h
M clang/lib/Format/TokenAnnotator.cpp
M clang/lib/Format/UnwrappedLineParser.cpp
M clang/unittests/Format/FormatTest.cpp
M clang/unittests/Format/TokenAnnotatorTest.cpp
Log Message:
-----------
[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
Commit: 4134f836103ebc70cc23a80c7a966d1d5f3a6353
https://github.com/llvm/llvm-project/commit/4134f836103ebc70cc23a80c7a966d1d5f3a6353
Author: sstwcw <f0gukp2nk at protonmail.com>
Date: 2023-04-30 (Sun, 30 Apr 2023)
Changed paths:
M clang/lib/Format/TokenAnnotator.cpp
M clang/unittests/Format/FormatTestVerilog.cpp
M clang/unittests/Format/TokenAnnotatorTest.cpp
Log Message:
-----------
[clang-format] Recognize Verilog type dimension in module header
We had the function `verilogGroupDecl` for that. However, the type
name would be incorrectly annotated in `isStartOfName` when it was not
a C++ keyword and followed another identifier.
Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D149352
Compare: https://github.com/llvm/llvm-project/compare/0a57d4d490a4...4134f836103e
More information about the All-commits
mailing list