[PATCH] D28165: Change clang-format's Chromium JavaScript defaults

Dan Beam via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 29 12:39:04 PST 2016


danbeam created this revision.
danbeam added a reviewer: thakis.
danbeam added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Chromium is starting to use clang-format on more JavaScript.

In doing this, we discovered that our defaults were not doing a good job differentiating between JS and C++.

This change moves some defaults to only apply to C++.


https://reviews.llvm.org/D28165

Files:
  lib/Format/Format.cpp


Index: lib/Format/Format.cpp
===================================================================
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -639,13 +639,17 @@
     ChromiumStyle.ContinuationIndentWidth = 8;
     ChromiumStyle.IndentWidth = 4;
   } else {
+    ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
+    ChromiumStyle.AllowShortLoopsOnASingleLine = false;
+  }
+
+  if (Language == FormatStyle::LK_Cpp) {
     ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false;
     ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
-    ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
-    ChromiumStyle.AllowShortLoopsOnASingleLine = false;
     ChromiumStyle.BinPackParameters = false;
     ChromiumStyle.DerivePointerAlignment = false;
   }
+
   ChromiumStyle.SortIncludes = false;
   return ChromiumStyle;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28165.82689.patch
Type: text/x-patch
Size: 878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161229/561f4cbe/attachment.bin>


More information about the cfe-commits mailing list