r309713 - clang-format: [JS] no whitespace between typeof operator and l_paren.

Martin Probst via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 1 10:42:16 PDT 2017


Author: mprobst
Date: Tue Aug  1 10:42:16 2017
New Revision: 309713

URL: http://llvm.org/viewvc/llvm-project?rev=309713&view=rev
Log:
clang-format: [JS] no whitespace between typeof operator and l_paren.

Modified:
    cfe/trunk/lib/Format/FormatToken.h
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=309713&r1=309712&r2=309713&view=diff
==============================================================================
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Tue Aug  1 10:42:16 2017
@@ -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<IdentifierInfo *>(
         {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;
 

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=309713&r1=309712&r2=309713&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Aug  1 10:42:16 2017
@@ -2353,7 +2353,7 @@ bool TokenAnnotator::spaceRequiredBefore
         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) ||

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=309713&r1=309712&r2=309713&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Aug  1 10:42:16 2017
@@ -263,6 +263,7 @@ TEST_F(FormatTestJS, ReservedWordsParent
   // 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");




More information about the cfe-commits mailing list