[PATCH] clang-format: Add ability to align assignment operators
Daniel Jasper
djasper at google.com
Tue Apr 7 04:39:12 PDT 2015
================
Comment at: docs/ClangFormatStyleOptions.rst:164
@@ +163,3 @@
+**AlignAssignmentOperators** (``bool``)
+ If ``true``, aligns assignment operators.
+
----------------
This is different from the comment below. Use docs/tools/dump_format_style.py.
================
Comment at: include/clang/Format/Format.h:250
@@ -249,1 +249,3 @@
+ /// \brief If \c true, aligns variable assignments.
+ bool AlignAssignmentOperators;
----------------
This comment is a bit brief. Add an example.
================
Comment at: lib/Format/Format.cpp:423
@@ -420,2 +422,3 @@
GoogleStyle.AlignTrailingComments = false;
+ GoogleStyle.AlignAssignmentOperators = false;
GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
----------------
This should be unnecessary as it is inherited from LLVMStyle.
================
Comment at: lib/Format/Format.cpp:483
@@ -479,2 +482,3 @@
Style.AlignTrailingComments = false;
+ Style.AlignAssignmentOperators = false;
Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
----------------
This should be unnecessary as it is inherited from LLVMStyle.
================
Comment at: lib/Format/WhitespaceManager.cpp:267
@@ -265,1 +266,3 @@
+void WhitespaceManager::alignAssignmentOperators() {
+ if (!Style.AlignAssignmentOperators)
----------------
What does this do if an assignment needs to be wrapped, i.e.:
LooooooooooongType looooooooongVariable =
someLooooooooooooooooongFunction();
int i = 1;
What does it do if there are multiple assignments in one statement, i.e.:
int i = 1, j = 2;
int abc = 3;
Does this align the assignments of statements other than DeclStmts? I.e. what is the result of:
int i = 1;
if (SomeType t = getSomething()) {}
int j = 7;
for (int k = 0; k < N; ++k) {}
Add tests.
================
Comment at: unittests/Format/FormatTest.cpp:8363
@@ +8362,3 @@
+ "int oneTwoThree = 123;", Alignment);
+ EXPECT_EQ("int a = 5;\n"
+ "int oneTwoThree = 123;",
----------------
Is there a particular reason, not to use verifyFormat everywhere?
http://reviews.llvm.org/D8821
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list