r290930 - Change clang-format's Chromium JavaScript defaults

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 3 18:33:36 PST 2017


Author: nico
Date: Tue Jan  3 20:33:36 2017
New Revision: 290930

URL: http://llvm.org/viewvc/llvm-project?rev=290930&view=rev
Log:
Change clang-format's Chromium JavaScript defaults

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

Patch from Dan Beam <dbeam at chromium.org>!

Modified:
    cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=290930&r1=290929&r2=290930&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Jan  3 20:33:36 2017
@@ -638,6 +638,9 @@ FormatStyle getChromiumStyle(FormatStyle
     ChromiumStyle.BreakAfterJavaFieldAnnotations = true;
     ChromiumStyle.ContinuationIndentWidth = 8;
     ChromiumStyle.IndentWidth = 4;
+  } else if (Language == FormatStyle::LK_JavaScript) {
+    ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
+    ChromiumStyle.AllowShortLoopsOnASingleLine = false;
   } else {
     ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false;
     ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;




More information about the cfe-commits mailing list