[PATCH] Support for JavaScript === and !== operators.

Alexander Kornienko alexfh at google.com
Wed Nov 20 06:02:25 PST 2013


  Phabricator doesn't see changes in unittests/Format/FormatTest.cpp, let's try again...

Hi klimek, djasper,

http://llvm-reviews.chandlerc.com/D2231

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2231?vs=5677&id=5678#toc

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1363,6 +1363,10 @@
   if (Tok.isOneOf(tok::arrowstar, tok::periodstar) ||
       Tok.Previous->isOneOf(tok::arrowstar, tok::periodstar))
     return false;
+  // JavaScript identity operators ===, !==.
+  if (Tok.Previous->isOneOf(tok::equalequal, tok::exclaimequal) &&
+      Tok.is(tok::equal))
+    return false;
   if (!Style.SpaceBeforeAssignmentOperators &&
       Tok.getPrecedence() == prec::Assignment)
     return false;
@@ -1452,6 +1456,9 @@
     return false;
   if (Left.is(tok::equal) && Line.Type == LT_VirtualFunctionDecl)
     return false;
+  // JavaScript identity operators ===, !==.
+  if (Left.isOneOf(tok::equalequal, tok::exclaimequal) && Right.is(tok::equal))
+    return false;
   if (Left.Previous) {
     if (Left.is(tok::l_paren) && Right.is(tok::l_paren) &&
         Left.Previous->is(tok::kw___attribute))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2231.2.patch
Type: text/x-patch
Size: 1014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131120/80ed1f47/attachment.bin>


More information about the cfe-commits mailing list