[PATCH] D59087: [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 7 03:31:44 PST 2019


MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: klimek, djasper, JonasToth, alexfh, krasimir.
MyDeveloperDay added a project: clang-tools-extra.
Herald added a subscriber: jdoerfert.

Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

  if(true) var++;
  else  {
      var--;
  }

is reformatted to be

  if (true)
    var++;
  else {
    var--;
  }

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a compound else


https://reviews.llvm.org/D59087

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59087.189680.patch
Type: text/x-patch
Size: 4187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190307/08eff926/attachment.bin>


More information about the cfe-commits mailing list