clang-format single line if

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

clang-format single line if

Kristof Beyls via cfe-dev
If I build clang-format from tip of master and run it
using this .clang-format file

  AllowShortIfStatementsOnASingleLine: Always

it will change this single line if statement

  if (x) { x++; }

into this three line if statement

  if (x) {
    x++;
  }

How do I keep it as one line?

If I delete the braces it stays on one line, but the
style guide for the code I work on says the braces are
required. If I modify my .clang-format file to be

  AllowShortIfStatementsOnASingleLine: Always
  AllowShortBlocksOnASingleLine: Always

it stays on one line, but I don't want all short blocks
on a single line, just the if statement block. Any ideas?

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang-format single line if

Kristof Beyls via cfe-dev
Could I ask you to log a defect over in  https://bugs.llvm.org to this effect, The examples using AllowShortIfStatementsOnASingleLine  don't include braces 

MyDeveloperDay

On Sun, Nov 3, 2019 at 8:51 PM Michael Pozulp via cfe-dev <[hidden email]> wrote:
If I build clang-format from tip of master and run it
using this .clang-format file

  AllowShortIfStatementsOnASingleLine: Always

it will change this single line if statement

  if (x) { x++; }

into this three line if statement

  if (x) {
    x++;
  }

How do I keep it as one line?

If I delete the braces it stays on one line, but the
style guide for the code I work on says the braces are
required. If I modify my .clang-format file to be

  AllowShortIfStatementsOnASingleLine: Always
  AllowShortBlocksOnASingleLine: Always

it stays on one line, but I don't want all short blocks
on a single line, just the if statement block. Any ideas?
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang-format single line if

Kristof Beyls via cfe-dev

On Mon, Nov 4, 2019 at 3:36 AM MyDeveloper Day <[hidden email]> wrote:
Could I ask you to log a defect over in  https://bugs.llvm.org to this effect, The examples using AllowShortIfStatementsOnASingleLine  don't include braces 

MyDeveloperDay

On Sun, Nov 3, 2019 at 8:51 PM Michael Pozulp via cfe-dev <[hidden email]> wrote:
If I build clang-format from tip of master and run it
using this .clang-format file

  AllowShortIfStatementsOnASingleLine: Always

it will change this single line if statement

  if (x) { x++; }

into this three line if statement

  if (x) {
    x++;
  }

How do I keep it as one line?

If I delete the braces it stays on one line, but the
style guide for the code I work on says the braces are
required. If I modify my .clang-format file to be

  AllowShortIfStatementsOnASingleLine: Always
  AllowShortBlocksOnASingleLine: Always

it stays on one line, but I don't want all short blocks
on a single line, just the if statement block. Any ideas?
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev