[PATCH] Fixes bug 20587 - Add K&R break before braces style

Daniel Jasper djasper at google.com
Sat Aug 9 13:47:18 PDT 2014


LOL.. Very interesting that no additional logic is necessary.

Looks good with a few minor comments.

================
Comment at: docs/ClangFormatStyleOptions.rst:176
@@ -175,1 +175,3 @@
+  * ``BS_KernighanRitchie`` (in configuration: ``KernighanRitchie``)
+    Like ``Attach``, but break before braces on function definitions.
 
----------------
Please generate this with docs/tools/dump_format_style.py. Otherwise, the next re-generation of this file will contain unrelated changes.

================
Comment at: include/clang/Format/Format.h:287
@@ +286,3 @@
+    BS_GNU,
+    /// Like \c Attach, but break before braces on named function
+    /// definitions.
----------------
"named"?

Also, maybe "..., but only break ..."?

================
Comment at: unittests/Format/FormatTest.cpp:8069
@@ +8068,3 @@
+TEST_F(FormatTest, KernighanRitchieBraceBreaking) {
+  FormatStyle BreakBeforeBrace = getLLVMStyle();
+  BreakBeforeBrace.BreakBeforeBraces = FormatStyle::BS_KernighanRitchie;
----------------
Call this KRStyle?

http://reviews.llvm.org/D4837






More information about the cfe-commits mailing list