summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-05-21 12:51:23 +0000
committerDaniel Jasper <djasper@google.com>2014-05-21 12:51:23 +0000
commitb16b969d7cd3b135328c0af6f85321d7b134d7fd (patch)
treefab6ee6c317882def203dea1537367e1615d6c60 /clang/lib/Format/Format.cpp
parent96ebc5d7db4bd23e6448e015e4f960e3264eb8ce (diff)
downloadbcm5719-llvm-b16b969d7cd3b135328c0af6f85321d7b134d7fd.tar.gz
bcm5719-llvm-b16b969d7cd3b135328c0af6f85321d7b134d7fd.zip
clang-format: [JS] Support different function literal style.
Before: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); After: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); llvm-svn: 209291
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ae8c75ff6dc..891a7188bba 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1146,8 +1146,13 @@ private:
return true;
if (NewLine) {
- int AdditionalIndent = State.Stack.back().Indent -
- Previous.Children[0]->Level * Style.IndentWidth;
+ int AdditionalIndent = 0;
+ if (State.Stack.size() < 2 ||
+ !State.Stack[State.Stack.size() - 2].JSFunctionInlined) {
+ AdditionalIndent = State.Stack.back().Indent -
+ Previous.Children[0]->Level * Style.IndentWidth;
+ }
+
Penalty += format(Previous.Children, DryRun, AdditionalIndent,
/*FixBadIndentation=*/true);
return true;
OpenPOWER on IntegriCloud