[PATCH] D44609: [Clang-Format] New option BreakBeforeLambdaBody to manage lambda line break inside function parameter call

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 26 06:01:57 PDT 2018


klimek added inline comments.


================
Comment at: include/clang/Format/Format.h:891
+  /// \endcode
+  bool BreakBeforeLambdaBody;
+
----------------
I'd just make that default for Allman style.


================
Comment at: lib/Format/TokenAnnotator.cpp:2844
   if (isAllmanBrace(Left) || isAllmanBrace(Right))
-    return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
+    return (Line.containsBefore(Right, TT_LambdaLSquare) && Style.BreakBeforeLambdaBody) ||
+           (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
----------------
Instead of parsing the whole line again, which can lead to false positives, you can add a TokenType for LambdaLBrace while parsing and use that here.


Repository:
  rC Clang

https://reviews.llvm.org/D44609





More information about the cfe-commits mailing list