summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-06-03 17:08:40 +0000
committerDaniel Jasper <djasper@google.com>2015-06-03 17:08:40 +0000
commit3c306e895e5e7f53950b4102e92fcf2266492b5c (patch)
tree886be3358393a5a0583a1365599ff97809088810 /clang/lib/Format
parent063d674c2112e2134f667f9a9dc3e0482de85dfe (diff)
downloadbcm5719-llvm-3c306e895e5e7f53950b4102e92fcf2266492b5c.tar.gz
bcm5719-llvm-3c306e895e5e7f53950b4102e92fcf2266492b5c.zip
clang-format: [JS] Let fat arrows have 'Equality' precedence.
This fixes a regression in literal formatting: Before: aaaaaaaaaaaaa = { aaaaaaaaaaaaaaaaaaaaaaaaaaaa: (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, }; After: var aaaaaaaaaaaaaaaaaaaa = { aaaaaaaaaaaaaaaaaaaaaaaaaaaa: (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, }; Also apply no-else-after-return policy. llvm-svn: 238942
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 993eb1d8b86..23ba2e870d1 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1320,25 +1320,27 @@ private:
const FormatToken *NextNonComment = Current->getNextNonComment();
if (Current->is(TT_ConditionalExpr))
return prec::Conditional;
- else if (NextNonComment && NextNonComment->is(tok::colon) &&
- NextNonComment->is(TT_DictLiteral))
+ if (NextNonComment && NextNonComment->is(tok::colon) &&
+ NextNonComment->is(TT_DictLiteral))
return prec::Comma;
- else if (Current->is(TT_LambdaArrow))
+ if (Current->is(TT_LambdaArrow))
return prec::Comma;
- else if (Current->isOneOf(tok::semi, TT_InlineASMColon,
- TT_SelectorName, TT_JsComputedPropertyName) ||
- (Current->is(tok::comment) && NextNonComment &&
- NextNonComment->is(TT_SelectorName)))
+ if (Current->is(TT_JsFatArrow))
+ return prec::Equality;
+ if (Current->isOneOf(tok::semi, TT_InlineASMColon, TT_SelectorName,
+ TT_JsComputedPropertyName) ||
+ (Current->is(tok::comment) && NextNonComment &&
+ NextNonComment->is(TT_SelectorName)))
return 0;
- else if (Current->is(TT_RangeBasedForLoopColon))
+ if (Current->is(TT_RangeBasedForLoopColon))
return prec::Comma;
- else if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
+ if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
return Current->getPrecedence();
- else if (Current->isOneOf(tok::period, tok::arrow))
+ if (Current->isOneOf(tok::period, tok::arrow))
return PrecedenceArrowAndPeriod;
- else if (Style.Language == FormatStyle::LK_Java &&
- Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements,
- Keywords.kw_throws))
+ if (Style.Language == FormatStyle::LK_Java &&
+ Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements,
+ Keywords.kw_throws))
return 0;
}
return -1;
OpenPOWER on IntegriCloud