summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-11-20 14:30:26 +0000
committerAlexander Kornienko <alexfh@google.com>2013-11-20 14:30:26 +0000
commit7c9c05076969157661e2ba20d6e12dfb04f7976f (patch)
tree629932416ea2db9ad26fa0d9c4df916ab2e30fdf /clang/lib
parent3e29c6bf229ac209d56dc8a576b9c61d98e21c6f (diff)
downloadbcm5719-llvm-7c9c05076969157661e2ba20d6e12dfb04f7976f.tar.gz
bcm5719-llvm-7c9c05076969157661e2ba20d6e12dfb04f7976f.zip
Support for JavaScript === and !== operators.
Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2231 llvm-svn: 195251
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 074e1d78454..3aee3a03945 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1363,6 +1363,10 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
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 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
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))
OpenPOWER on IntegriCloud