objective-ccode-formattinguncrustifyllvm-4.0

Uncrustify doesn't support for the new Objective-C syntax of LLVM 4.0


I have used Uncrustify for formatting code.

But Uncrustify doesn't support for the new Objective-C syntax of LLVM 4.0.

What am I going to do?

The Code formated by Uncrustify:

@interface SJTLLVM4Tester()
@property (strong) NSNumber *number;
@end

@implementation SJTLLVM4Tester
-(id)init {
    self = [super init];
    if (self) {
        self.number = @'C';
        self.number = @123;
        self.number = @0x123ul;
        self.number = @-1.2e-3f;
        self.number = @YES;

        NSDictionary *dictionary = @{@"key1":@1,@"key2":@2,@"key3":@3};
        NSMutableArray *array = [[NSMutableArray alloc] initWithArray:@[@1,@2,@3]];

        self.number = dictionary[@"key1"];
        array[0] = self.number;
    }
    return self;
}
@end

The execution result: Result


Solution

  • This has been fixed in the latest uncrustify release : 0.60.

    You can grab it here : https://github.com/bengardner/uncrustify/archive/uncrustify-0.60.tar.gz

    I'm using Brew and had to manually update the URL & SHA1 with brew edit uncrustify and then brew upgrade uncrustify.

    Below is my new formula :

    require 'formula'
    
    class Uncrustify < Formula
      url 'http://downloads.sourceforge.net/project/uncrustify/uncrustify/uncrustify-0.60/uncrustify-0.60.tar.gz'
      head 'https://github.com/bengardner/uncrustify.git'
      homepage 'http://uncrustify.sourceforge.net/'
      sha1 '769a7649a1cefb80beff9b67b11b4b87a8cc8e0e'
    
      def install
        system "./configure", "--prefix=#{prefix}", "--disable-dependency-tracking"
        system "make install"
      end
    end
    

    Works like a charm now.