r200469 - clang-format: Support ObjC's NS_ENUMs.
Jordan Rose
jordan_rose at apple.com
Thu Jan 30 09:01:41 PST 2014
The other ones like this are NS_OPTIONS, CF_ENUM, and CF_OPTIONS.
On Jan 30, 2014, at 6:38 , Daniel Jasper <djasper at google.com> wrote:
> Author: djasper
> Date: Thu Jan 30 08:38:37 2014
> New Revision: 200469
>
> URL: http://llvm.org/viewvc/llvm-project?rev=200469&view=rev
> Log:
> clang-format: Support ObjC's NS_ENUMs.
>
> 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
> };
>
> Modified:
> cfe/trunk/lib/Format/UnwrappedLineParser.cpp
> cfe/trunk/unittests/Format/FormatTest.cpp
>
> Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=200469&r1=200468&r2=200469&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Jan 30 08:38:37 2014
> @@ -668,6 +668,12 @@ void UnwrappedLineParser::parseStructura
> 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:
> @@ -1129,7 +1135,10 @@ void UnwrappedLineParser::parseAccessSpe
> }
>
> 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))
>
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=200469&r1=200468&r2=200469&view=diff
> ==============================================================================
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan 30 08:38:37 2014
> @@ -1713,6 +1713,18 @@ TEST_F(FormatTest, FormatsEnumTypes) {
> 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"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list