Before:
typedef NS_ENUM(NSInteger, MyType) {
/// Information about someDecentlyLongValue.
someDecentlyLongValue,
/// Information about anotherDecentlyLongValue.
anotherDecentlyLongValue,
/// Information about aThirdDecentlyLongValue.
aThirdDecentlyLongValue};
After:
typedef NS_ENUM(NSInteger, MyType) {
/// Information about someDecentlyLongValue.
someDecentlyLongValue,
/// Information about anotherDecentlyLongValue.
anotherDecentlyLongValue,
/// Information about aThirdDecentlyLongValue.
aThirdDecentlyLongValue
};
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200469
91177308-0d34-0410-b5e6-
96231b3b80d8
case tok::kw_enum:
parseEnum();
break;
+ case tok::kw_typedef:
+ nextToken();
+ // FIXME: Use the IdentifierTable instead.
+ if (FormatTok->TokenText == "NS_ENUM")
+ parseEnum();
+ break;
case tok::kw_struct:
case tok::kw_union:
case tok::kw_class:
}
void UnwrappedLineParser::parseEnum() {
- nextToken();
+ if (FormatTok->Tok.is(tok::kw_enum)) {
+ // Won't be 'enum' for NS_ENUMs.
+ nextToken();
+ }
// Eat up enum class ...
if (FormatTok->Tok.is(tok::kw_class) ||
FormatTok->Tok.is(tok::kw_struct))
verifyFormat("enum X : std::uint32_t { A, B };");
}
+TEST_F(FormatTest, FormatsNSEnums) {
+ verifyGoogleFormat("typedef NS_ENUM(NSInteger, SomeName) { AAA, BBB }");
+ verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n"
+ " // Information about someDecentlyLongValue.\n"
+ " someDecentlyLongValue,\n"
+ " // Information about anotherDecentlyLongValue.\n"
+ " anotherDecentlyLongValue,\n"
+ " // Information about aThirdDecentlyLongValue.\n"
+ " aThirdDecentlyLongValue\n"
+ "};");
+}
+
TEST_F(FormatTest, FormatsBitfields) {
verifyFormat("struct Bitfields {\n"
" unsigned sClass : 8;\n"