[PATCH] D107961: [clang-format] Distinguish K&R C function definition and attribute

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 13 04:01:03 PDT 2021


owenpan added a comment.

In D107961#2943291 <https://reviews.llvm.org/D107961#2943291>, @MyDeveloperDay wrote:

>> The above C++ declarations should be inside a class definition, no?
>
> Not really, we don't have to have any context of where we are (in class or struct). if you had  for example
>
>   class A
>   {
>   #include "myfunctions.h"
>   }
>
> you still would want the code in myfunctions.h to be formatted just the same (less indentation)

Got it!

> So the following code:
>
>   bool foo(int a, Bar)
>   override;
>   bool foo(int a, Bar)
>   override; // comment
>
> Failed on the 13 branch, but is fixed with @krasimir fix, but that isn't backported (we need to do that as a minimum I think)
>
> With this revision that is also fixed, the following occurs if I change the return type
>
>   Bar foo(int a, Bar)
>   override;
>   Bar foo(int a, Bar)
>   override; // comment
>
> And that doesn't feel correct to me. Well not as by default at least. From my perspective there seems to be a propensity to think code is K&R, but that should be the exception not the rule.

I agree.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107961/new/

https://reviews.llvm.org/D107961



More information about the cfe-commits mailing list