aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/FormatTokenLexer.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-05-04 15:04:04 +0000
committerMartin Probst <martin@probst.io>2017-05-04 15:04:04 +0000
commit4ef0370e6dbd6fb995eb89ad943a93e0995aed44 (patch)
treeeed6af0a1d0cd401f58223da98aa1c7048de46a6 /clang/lib/Format/FormatTokenLexer.cpp
parent808f2d3c620f922b6bab2b5275b6a83d6eb69221 (diff)
downloadllvm-4ef0370e6dbd6fb995eb89ad943a93e0995aed44.zip
llvm-4ef0370e6dbd6fb995eb89ad943a93e0995aed44.tar.gz
llvm-4ef0370e6dbd6fb995eb89ad943a93e0995aed44.tar.bz2
clang-format: [JS] exponentiation operator
Summary: While its precedence should be higher than multiplicative, LLVM does not have a level for that, so for the time being just treat it as multiplicative. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32864 llvm-svn: 302156
Diffstat (limited to 'clang/lib/Format/FormatTokenLexer.cpp')
-rw-r--r--clang/lib/Format/FormatTokenLexer.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp
index 1acc0c3..45c3ae1 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,10 @@ void FormatTokenLexer::tryMergePreviousTokens() {
static const tok::TokenKind JSShiftEqual[] = {tok::greater, tok::greater,
tok::greaterequal};
static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
+ static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
+ static const tok::TokenKind JSExponentiationEqual[] = {tok::star,
+ tok::starequal};
+
// FIXME: Investigate what token type gives the correct operator priority.
if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
return;
@@ -83,6 +87,12 @@ void FormatTokenLexer::tryMergePreviousTokens() {
return;
if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
return;
+ if (tryMergeTokens(JSExponentiation, TT_JsExponentiation))
+ return;
+ if (tryMergeTokens(JSExponentiationEqual, TT_JsExponentiationEqual)) {
+ Tokens.back()->Tok.setKind(tok::starequal);
+ return;
+ }
}
if (Style.Language == FormatStyle::LK_Java) {