Take operator precedence into account when splitting lines.

With this patch, splitting after binary operators has a panelty corresponding
to the operator's precedence. We used to ignore this and eagerly format like:

  if (aaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbbbbbbb &&
      ccccccccccccccccccccccccc) { .. }

With this patch, this becomes:

  if (aaaaaaaaaaaaaaaaaaaaaaaaa ||
      bbbbbbbbbbbbbbbbbbbbbbbbb && ccccccccccccccccccccccccc) { .. }

llvm-svn: 171007
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2a8fbd6..ad85a8e 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -90,7 +90,7 @@
       : Style(Style), SourceMgr(SourceMgr), Line(Line),
         Annotations(Annotations), Replaces(Replaces),
         StructuralError(StructuralError) {
-    Parameters.PenaltyIndentLevel = 5;
+    Parameters.PenaltyIndentLevel = 15;
   }
 
   void format() {
@@ -325,10 +325,14 @@
 
     if (Left.Tok.is(tok::semi) || Left.Tok.is(tok::comma))
       return 0;
-    if (Left.Tok.is(tok::equal) || Left.Tok.is(tok::l_paren) ||
-        Left.Tok.is(tok::pipepipe) || Left.Tok.is(tok::ampamp))
+    if (Left.Tok.is(tok::l_paren))
       return 2;
 
+    prec::Level Level =
+        getBinOpPrecedence(Line.Tokens[Index].Tok.getKind(), true, true);
+    if (Level != prec::Unknown)
+      return Level;
+
     if (Right.Tok.is(tok::arrow) || Right.Tok.is(tok::period))
       return 200;