diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-01-24 22:00:03 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-01-24 22:00:03 +0000 |
commit | 480093f4440d54b30b3025afeac24b48f2ba7a2e (patch) | |
tree | 162e72994062888647caf0d875428db9445491a8 /contrib/llvm-project/clang/lib/Format/FormatTokenLexer.cpp | |
parent | 489b1cf2ecf5b9b4a394857987014bfb09067726 (diff) | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'contrib/llvm-project/clang/lib/Format/FormatTokenLexer.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Format/FormatTokenLexer.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/llvm-project/clang/lib/Format/FormatTokenLexer.cpp b/contrib/llvm-project/clang/lib/Format/FormatTokenLexer.cpp index 5d8a77577c0b..ef20ba884fb3 100644 --- a/contrib/llvm-project/clang/lib/Format/FormatTokenLexer.cpp +++ b/contrib/llvm-project/clang/lib/Format/FormatTokenLexer.cpp @@ -100,6 +100,10 @@ void FormatTokenLexer::tryMergePreviousTokens() { static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star}; static const tok::TokenKind JSExponentiationEqual[] = {tok::star, tok::starequal}; + static const tok::TokenKind JSNullPropagatingOperator[] = {tok::question, + tok::period}; + static const tok::TokenKind JSNullishOperator[] = {tok::question, + tok::question}; // FIXME: Investigate what token type gives the correct operator priority. if (tryMergeTokens(JSIdentity, TT_BinaryOperator)) @@ -116,6 +120,14 @@ void FormatTokenLexer::tryMergePreviousTokens() { Tokens.back()->Tok.setKind(tok::starequal); return; } + if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator)) + return; + if (tryMergeTokens(JSNullPropagatingOperator, + TT_JsNullPropagatingOperator)) { + // Treat like a regular "." access. + Tokens.back()->Tok.setKind(tok::period); + return; + } if (tryMergeJSPrivateIdentifier()) return; } |