]> granicus.if.org Git - clang/commitdiff
Change clang-format's Chromium JavaScript defaults
authorNico Weber <nicolasweber@gmx.de>
Wed, 4 Jan 2017 02:33:36 +0000 (02:33 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 4 Jan 2017 02:33:36 +0000 (02:33 +0000)
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@chromium.org>!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290930 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp

index 70b90d6fa14e0cb2716dbf906759082d6ad2b36f..389761d4824986738e47d8812267bc829a1fd315 100644 (file)
@@ -638,6 +638,9 @@ FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) {
     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;