From 9926abb91fc8eda6d5a40dd59b73d498eabb81d2 Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Tue, 1 Aug 2017 17:42:16 +0000 Subject: [PATCH] clang-format: [JS] no whitespace between typeof operator and l_paren. llvm-svn: 309713 --- clang/lib/Format/FormatToken.h | 4 +++- clang/lib/Format/TokenAnnotator.cpp | 2 +- clang/unittests/Format/FormatTestJS.cpp | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index a60361a8e5fa..0cf5430fbf70 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -644,6 +644,7 @@ struct AdditionalKeywords { kw_readonly = &IdentTable.get("readonly"); kw_set = &IdentTable.get("set"); kw_type = &IdentTable.get("type"); + kw_typeof = &IdentTable.get("typeof"); kw_var = &IdentTable.get("var"); kw_yield = &IdentTable.get("yield"); @@ -680,7 +681,7 @@ struct AdditionalKeywords { JsExtraKeywords = std::unordered_set( {kw_as, kw_async, kw_await, kw_declare, kw_finally, kw_from, kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_readonly, - kw_set, kw_type, kw_var, kw_yield, + kw_set, kw_type, kw_typeof, kw_var, kw_yield, // Keywords from the Java section. kw_abstract, kw_extends, kw_implements, kw_instanceof, kw_interface}); } @@ -714,6 +715,7 @@ struct AdditionalKeywords { IdentifierInfo *kw_readonly; IdentifierInfo *kw_set; IdentifierInfo *kw_type; + IdentifierInfo *kw_typeof; IdentifierInfo *kw_var; IdentifierInfo *kw_yield; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 150d786c3333..7ea34d49be3d 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2353,7 +2353,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, Left.Tok.getIdentifierInfo()) return false; if (Right.is(tok::l_paren) && - Left.isOneOf(tok::kw_throw, Keywords.kw_await, tok::kw_void)) + Left.isOneOf(tok::kw_throw, Keywords.kw_await, Keywords.kw_typeof, tok::kw_void)) return true; if ((Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in, tok::kw_const) || diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 02d608eadfe1..06f096a1d62d 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -263,6 +263,7 @@ TEST_F(FormatTestJS, ReservedWordsParenthesized) { // All of these are statements using the keyword, not function calls. verifyFormat("throw (x + y);\n" "await (await x).y;\n" + "typeof (x) === 'string';\n" "void (0);\n" "delete (x.y);\n" "return (x);\n");