[PATCH] D106349: [clang-format] respect AfterEnum for enums
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 3 11:01:19 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7972b2e42276: [clang-format] respect AfterEnum for enums (authored by m1cha, committed by curdeius).
Changed prior to commit:
https://reviews.llvm.org/D106349?vs=361493&id=397106#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106349/new/
https://reviews.llvm.org/D106349
Files:
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2535,6 +2535,13 @@
" C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+ verifyFormat("typedef enum\n"
+ "{\n"
+ " A,\n"
+ " B,\n"
+ " C\n"
+ "} ShortEnum1, ShortEnum2;",
+ Style);
}
TEST_F(FormatTest, ShortCaseLabels) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -782,6 +782,8 @@
return Style.BraceWrapping.AfterUnion;
if (InitialToken.is(tok::kw_struct))
return Style.BraceWrapping.AfterStruct;
+ if (InitialToken.is(tok::kw_enum))
+ return Style.BraceWrapping.AfterEnum;
return false;
}
@@ -2606,12 +2608,12 @@
}
bool UnwrappedLineParser::parseEnum() {
+ const FormatToken &InitialToken = *FormatTok;
+
// Won't be 'enum' for NS_ENUMs.
if (FormatTok->Tok.is(tok::kw_enum))
nextToken();
- const FormatToken &InitialToken = *FormatTok;
-
// In TypeScript, "enum" can also be used as property name, e.g. in interface
// declarations. An "enum" keyword followed by a colon would be a syntax
// error and thus assume it is just an identifier.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106349.397106.patch
Type: text/x-patch
Size: 1492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220103/f816963b/attachment.bin>
More information about the cfe-commits
mailing list