[clang] [polly] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 29 19:27:47 PST 2024


rmarker wrote:

> > > @mydeveloperday @HazardyKnusperkeks @rymiel this patch fixes a very old bug and will cause behavior changes whether the default is changed to the new `AllowShortType` or left at `None`. Which way should we go?
> > 
> > 
> > Now I'm leaning toward keeping the existing (buggy) behavior of `None` and using the new `AllowShortType` to allow wrapping after short return types.
> 
> Buggy would be no break? That would be what I expect from `None`. :) So +1 from me.

`None` prevents breaks after short return types. The buggy behaviour is that it doesn't take leading indentation into account when determining if a return type is short or not. This means that if there is indentation, it wouldn't think a type is short that otherwise would be, and would thus allow a break after the return type.
Fixing the bug would cause return types in more situations to be identified as short and thus prevent breaks previously allowed (changing the previous behaviour).

 ```
 // Buggy None
void LongName::
      AnotherLongName();
class C {
   void
   LongName::AnotherLongName();
};

// Fixed None
void LongName::
      AnotherLongName();
class C {
   void LongName::
        AnotherLongName();
};
 ```

https://github.com/llvm/llvm-project/pull/78011


More information about the cfe-commits mailing list