clang-format: Introduce stricter AlignOperands flag
authorFrancois Ferrand <thetypz@gmail.com>
Mon, 22 May 2017 09:23:08 +0000 (11:23 +0200)
committerFrancois Ferrand <francois.ferrand@faurecia.com>
Wed, 22 Apr 2020 15:36:38 +0000 (17:36 +0200)
commit3d61b1120e8267aa39f4c9a33d618dbaec4ec6fa
tree29276258cf21b36612fe4984e733c498d2f23c1b
parent5daa25fd7a184524759b6ad065a8bd7e95aa149a
clang-format: Introduce stricter AlignOperands flag

Summary:
Even when BreakBeforeBinaryOperators is set, AlignOperands kept
aligning the beginning of the line, even when it could align the
actual operands (e.g. after an assignment).

With this patch, there is an option to actually align the operands, so
that the operator gets right-aligned with the equal sign or return
operator:

  int aaaaa = bbbbbb
            + cccccc;
  return aaaaaaa
      && bbbbbbb;

This not happen in parentheses, to avoid 'breaking' the indentation:

  if (aaaaa
      && bbbbb)
    return;

Reviewers: krasimir, djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D32478
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/ContinuationIndenter.h
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestJS.cpp