[PATCH] D80950: [clang-format] [PR44542,38872] String << String always get a forced newline.

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 01:35:00 PDT 2020


MyDeveloperDay added a comment.

@sammccall  in the example

  LOG_IF(DFATAL, exp_await_calls < num_await_calls_)
      << "Equality condition can never be satisfied:"
      << " exp_await_calls=" << exp_await_calls
      << " num_await_calls_=" << num_await_calls_;

I agree this is more pleasing, however Its ONLY broken this was because of your LineLimit and the variable lengths

The same function with smaller variables isn't quite so readable

  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
                        << " foo=" << a << " bar=" << b;

and there is inconsistency between

  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
                        << " foo=" << a << " is less than "
                        << " bar=" << b;



  std::string reason = " is less than ";
  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
                        << " foo=" << a << reason << " bar=" << b;

I could see value in allowing (AlwaysBreak) (as this really help to show the need for a space before the `"foo=,is less and bar="`)

  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
                        << " foo="
                        << a
                        << " is less than "
                        << " bar="
                        << b;

and also not enforcing any breaking other than line length (Never)

  std::string reason = " is less than ";
  LOG_IF(DFATAL, a < b) << "=" << " foo=" << a << reason << " bar=" << b;

because that actually looks a little better IMHO than

  std::string reason = " is less than ";
  LOG_IF(DFATAL, a < b) << "="
                        << " foo=" << a << reason << " bar=" << b;

But whatever we do I think we should leave the current one as the default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80950





More information about the cfe-commits mailing list