r200469 - clang-format: Support ObjC's NS_ENUMs.

Daniel Jasper djasper at google.com
Fri Dec 5 02:43:26 PST 2014


Thanks. Finally got around to fixing this in r223458.

On Thu, Jan 30, 2014 at 6:01 PM, Jordan Rose <jordan_rose at apple.com> wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141205/05552da5/attachment.html>


More information about the cfe-commits mailing list