Skip to contentSkip to conversation

clang-format: Set IndentWrappedFunctionNames false

PATCH Superseded Jason Gunthorpe 3 participants 7 messages Jun 6, 2018 – Jun 7, 2018 Clang-format file

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clang-format: Set IndentWrappedFunctionNames false

The true option causes this indenting for functions:

static struct something_very_very_long *
function(void *arg)
{

While a quick survey suggests that the usual Linux fallback is the GNU style:

static struct something_very_very_long *
function(void *arg)
{

Eg as seen in:

kernel/cpu.c
kernel/fork.c

and other places.

---
 .clang-format | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks for making this Miguel!

I've been using clang-format for years with the kernel and noticed it was performing just a little different than I would have expected.

AFAIK the above describes the more common choice in the code base?

Not sure who's tree this is supposed to go through.. Andrew I guess?

.clang-format +1 -1
index faffc0d5af4eeb..1d5da22e0ba50c 100644
@@ -382,7 +382,7 @@ IncludeIsMainRegex: '(Test)?$'
 IndentCaseLabels: false
 #IndentPPDirectives: None # Unknown to clang-format-5.0
 IndentWidth: 8
-IndentWrappedFunctionNames: true
+IndentWrappedFunctionNames: false
 JavaScriptQuotes: Leave
 JavaScriptWrapImports: true
 KeepEmptyLinesAtTheStartOfBlocks: false
Signature · 1 line
2.17.0
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Jason Gunthorpe

The true option causes this indenting for functions:

static struct something_very_very_long *
function(void *arg)
{

Quoted 6 lines

While a quick survey suggests that the usual Linux fallback is the GNU style:

static struct something_very_very_long *
function(void *arg)

[]

Quoted 3 lines

AFAIK the above describes the more common choice in the code base?

Not sure who's tree this is supposed to go through.. Andrew I guess?

I believe so yes.

I expect there will be more refinements to .clang-formata as perhaps more people experiment with it too.

Quoted 13 lines
.clang-format +1 -1
index faffc0d5af4eeb..1d5da22e0ba50c 100644
@@ -382,7 +382,7 @@ IncludeIsMainRegex: '(Test)?$'
 IndentCaseLabels: false
 #IndentPPDirectives: None # Unknown to clang-format-5.0
 IndentWidth: 8
-IndentWrappedFunctionNames: true
+IndentWrappedFunctionNames: false
 JavaScriptQuotes: Leave
 JavaScriptWrapImports: true
 KeepEmptyLinesAtTheStartOfBlocks: false
#2 lore raw
Quoted 16 lines · Joe Perches
Quoted 6 lines · Jason Gunthorpe

The true option causes this indenting for functions:

static struct something_very_very_long *
function(void *arg)
{

Quoted 6 lines

While a quick survey suggests that the usual Linux fallback is the GNU style:

static struct something_very_very_long *
function(void *arg)

[]

Quoted 2 lines

AFAIK the above describes the more common choice in the code base?

Quoted 8 lines
Quoted 1 line

Not sure who's tree this is supposed to go through.. Andrew I guess?

I believe so yes.

I expect there will be more refinements to .clang-formata as perhaps more people experiment with it too.

Thanks Joe,

I saw your note in the original mailing-list thread and just wanted to say the way I use clang-format is editor based.

I have a hotkey that triggers clang-format to reformat the current statement, or current hi-lighted region. If I don't like it, then 'undo' puts it all back for manual adjustment..

This way I am selective of where I apply it, and I find it is something like 95% of the time good, IHMO.

Big time saver for wrapping long lines, moving code around (eg indent,de-indent) and other mundane daily tasks.

Cheers,
Jason

#3 lore raw
Quoted 7 lines · Jason Gunthorpe

I saw your note in the original mailing-list thread and just wanted to say the way I use clang-format is editor based.

I have a hotkey that triggers clang-format to reformat the current statement, or current hi-lighted region. If I don't like it, then 'undo' puts it all back for manual adjustment..

Quoted 5 lines

This way I am selective of where I apply it, and I find it is something like 95% of the time good, IHMO.

Big time saver for wrapping long lines, moving code around (eg indent,de-indent) and other mundane daily tasks.

Cool for you.

I do most of that via emacs indent-region but perhaps for rewrapping content and such, clang-format-region could be even better.

I'll give it a go one day.

cheers, Joe

#4 lore raw
In reply to Jason Gunthorpe
Quoted 35 lines · Jason Gunthorpe
Quoted 16 lines · Joe Perches
Quoted 6 lines · Jason Gunthorpe

The true option causes this indenting for functions:

static struct something_very_very_long *
function(void *arg)
{

Quoted 6 lines

While a quick survey suggests that the usual Linux fallback is the GNU style:

static struct something_very_very_long *
function(void *arg)

[]

Quoted 2 lines

AFAIK the above describes the more common choice in the code base?

Quoted 8 lines
Quoted 1 line

Not sure who's tree this is supposed to go through.. Andrew I guess?

I believe so yes.

I expect there will be more refinements to .clang-formata as perhaps more people experiment with it too.

Thanks Joe,

I saw your note in the original mailing-list thread and just wanted to say the way I use clang-format is editor based.

I have a hotkey that triggers clang-format to reformat the current statement, or current hi-lighted region. If I don't like it, then 'undo' puts it all back for manual adjustment..

Quoted 5 lines

This way I am selective of where I apply it, and I find it is something like 95% of the time good, IHMO.

Big time saver for wrapping long lines, moving code around (eg indent,de-indent) and other mundane daily tasks.

Indeed, I agree that currently this is the best way to use it (until and if we get full support for the kernel style in clang). In the documentation I wrote I mentioned this point. It can also be useful file-wide to quickly spot style issues: apply clang-format - inspect git diff - reset back.

Cheers,
Miguel

Quoted 3 lines

Cheers,
Jason

#5 lore raw
In reply to Joe Perches
Quoted 14 lines · Joe Perches
Quoted 6 lines · Jason Gunthorpe

The true option causes this indenting for functions:

static struct something_very_very_long *
function(void *arg)
{

Quoted 6 lines

While a quick survey suggests that the usual Linux fallback is the GNU style:

static struct something_very_very_long *
function(void *arg)

[]

Quoted 8 lines
Quoted 3 lines

AFAIK the above describes the more common choice in the code base?

Not sure who's tree this is supposed to go through.. Andrew I guess?

I believe so yes.

I expect there will be more refinements to .clang-formata as perhaps more people experiment with it too.

Yes, indeed! The version I committed was an initial approximation -- don't expect it to be the "final" or "official" one!

Cheers,
Miguel

Quoted 16 lines
Quoted 13 lines
.clang-format +1 -1
index faffc0d5af4eeb..1d5da22e0ba50c 100644
@@ -382,7 +382,7 @@ IncludeIsMainRegex: '(Test)?$'
 IndentCaseLabels: false
 #IndentPPDirectives: None # Unknown to clang-format-5.0
 IndentWidth: 8
-IndentWrappedFunctionNames: true
+IndentWrappedFunctionNames: false
 JavaScriptQuotes: Leave
 JavaScriptWrapImports: true
 KeepEmptyLinesAtTheStartOfBlocks: false
#6 lore raw
In reply to Jason Gunthorpe
Quoted 18 lines · Jason Gunthorpe

The true option causes this indenting for functions:

static struct something_very_very_long *
function(void *arg)
{

While a quick survey suggests that the usual Linux fallback is the GNU style:

static struct something_very_very_long *
function(void *arg)
{

Eg as seen in:

kernel/cpu.c
kernel/fork.c

Quoted 8 lines

and other places.

---
 .clang-format | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks for making this Miguel!

You're welcome! It is great to see people already using it. :-)

Quoted 5 lines

I've been using clang-format for years with the kernel and noticed it was performing just a little different than I would have expected.

AFAIK the above describes the more common choice in the code base?

Could be -- I took a look at several places and to the official guidelines; but I am sure I may have missed some things :-) For some options where I was unsure, I ran it through several "popular"/common folders and see which one generated a smaller git diff -- maybe you can try that and see what you get (also, it would be great if you can try some others outside kernel/*).

Quoted 2 lines

Not sure who's tree this is supposed to go through.. Andrew I guess?

It went through Andre the first time. In any case, I think it is fine to send it through any one.

Cheers,
Miguel

Quoted 17 lines
.clang-format +1 -2
index faffc0d5af4eeb..1d5da22e0ba50c 100644
@@ -382,7 +382,7 @@ IncludeIsMainRegex: '(Test)?$'
 IndentCaseLabels: false
 #IndentPPDirectives: None # Unknown to clang-format-5.0
 IndentWidth: 8
-IndentWrappedFunctionNames: true
+IndentWrappedFunctionNames: false
 JavaScriptQuotes: Leave
 JavaScriptWrapImports: true
 KeepEmptyLinesAtTheStartOfBlocks: false
--

2.17.0