[cfe-users] clang-format single line if

Michael Pozulp via cfe-users cfe-users at lists.llvm.org
Fri Nov 1 14:42:11 PDT 2019


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20191101/d26f187e/attachment.html>


More information about the cfe-users mailing list