From d02be1a6a5673cb545b9cfc58b350ea2a2405817 Mon Sep 17 00:00:00 2001
From: Daniel Jasper <djasper@google.com>
Date: Sat, 23 Nov 2013 14:45:49 +0000
Subject: [PATCH] clang-format: The "<" of a template argument is not a binary
 operator.

With Style.BreakBeforeBinaryOperators, clang-format breaks incorrectly.
This fixes llvm.org/PR17994.

Before:
  return boost::fusion::at_c<0>(iiii).second == boost::fusion::at_c
                                                <1>(iiii).second;

After:
  return boost::fusion::at_c<0>(iiii).second ==
         boost::fusion::at_c<1>(iiii).second;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195552 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Format/TokenAnnotator.cpp   | 2 +-
 unittests/Format/FormatTest.cpp | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 53734bcd51..e841b94474 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -1492,7 +1492,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
   if (Right.Type == TT_CtorInitializerComma &&
       Style.BreakConstructorInitializersBeforeComma)
     return true;
-  if (Right.isBinaryOperator() && Style.BreakBeforeBinaryOperators)
+  if (Right.Type == TT_BinaryOperator && Style.BreakBeforeBinaryOperators)
     return true;
   if (Left.is(tok::greater) && Right.is(tok::greater) &&
       Left.Type != TT_TemplateCloser)
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 97444dde84..f279c27274 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -2720,6 +2720,10 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
       "    + sizeof(int32_t) // Offset of CU in the .debug_info section\n"
       "    + sizeof(int8_t)  // Pointer Size (in bytes)\n"
       "    + sizeof(int8_t); // Segment Size (in bytes)");
+
+  verifyFormat("return boost::fusion::at_c<0>(iiii).second\n"
+               "       == boost::fusion::at_c<1>(iiii).second;",
+               Style);
 }
 
 TEST_F(FormatTest, ConstructorInitializers) {
-- 
2.40.0