[PATCH] D24574: clang-format: [JS] ASI insertion after boolean literals.

Martin Probst via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 18 10:30:38 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL281856: clang-format: [JS] ASI insertion after boolean literals. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D24574?vs=71385&id=71755#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24574

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -681,7 +681,9 @@
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
                                  const FormatToken *FormatTok) {
-  return FormatTok->Tok.isLiteral() || mustBeJSIdent(Keywords, FormatTok);
+  return FormatTok->Tok.isLiteral() ||
+         FormatTok->isOneOf(tok::kw_true, tok::kw_false) ||
+         mustBeJSIdent(Keywords, FormatTok);
 }
 
 // isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -774,6 +774,18 @@
                                       "String");
   verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
                                           "  bar) {}");
+  verifyFormat("a = true\n"
+               "return 1",
+               "a = true\n"
+               "  return   1");
+  verifyFormat("a = 's'\n"
+               "return 1",
+               "a = 's'\n"
+               "  return   1");
+  verifyFormat("a = null\n"
+               "return 1",
+               "a = null\n"
+               "  return   1");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24574.71755.patch
Type: text/x-patch
Size: 1494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160918/50f69650/attachment.bin>


More information about the cfe-commits mailing list