Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Should Allman-Brace breaking also done for nested blocks, e.g. lambdas and ObjC blocks? #23636

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR23637
Status NEW
Importance P enhancement
Reported by James Gregurich (bayoubengal@mac.com)
Reported on 2015-05-22 12:02:47 -0700
Last modified on 2018-03-04 23:47:29 -0800
Version 3.8
Hardware All All
CC djasper@google.com, jvapen@gmail.com, klimek@google.com, t_kuehn@maxon.de
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
please enhance the objc++ formatter so that objc blocks and c++ lambda's can be
formatted like so:

   [unusedCachedLayers enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSMutableSet *obj, BOOL *stop)
   {
      NSMutableSet *cacheSet = [unusedCachedLayers objectForKey:key];
      if ( cacheSet == nil )
      {
         DLog( @"unused cache set: %@ empty")
      }
      else
      {
         DLog( @"unused cache set: %@ count: %d" , key , [cacheSet count ]) ;
      }
   }];
Quuxplusone commented 9 years ago
NOTE:

the 'NSMutableSet *obj, BOOL *stop)' should not be wrapped. the bug reporter
did that.
Quuxplusone commented 8 years ago
+1,

this is also one of the things that destroys out code when formatting parts of
it with clang-format.

for code like:

if (condition)
{
    height = 1234;
    ParallelFor(0, height,
        [&](LocalData& myData) -> void
        {
            ...
        },
        [&](Int y, LocalData& myData) -> Result<void>
        {
            ...
        },
        [&](LocalData& myData)
        {
        },
        0, 16);
}

after formatting it is:

if (condition)
{
    height = 1234;
    ParallelFor(0, height,
        [&](LocalData& myData) -> void {
            ...
        },
        [&](Int y, LocalData& myData) -> Result<void> {
            ...
        },
        [&](LocalData& myData) {},
        0, 16);
}

it would be really cool if clang-format would respect the allman-brace option
also for lamdbas which are used alot nowadays.

thx