Improve handling of trailing 'const'.

Reduce the preference for breaking before a trailing 'const' according
to review comments on r182362.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182455 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index c8cdac9..598eb1a 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -959,6 +959,10 @@
     return 150;
   }
 
+  // Breaking before a trailing 'const' is bad.
+  if (Left.is(tok::r_paren) && Right.is(tok::kw_const))
+    return 150;
+
   // In for-loops, prefer breaking at ',' and ';'.
   if (Line.First.is(tok::kw_for) && Left.is(tok::equal))
     return 4;
@@ -1165,6 +1169,11 @@
     // change the "binding" behavior of a comment.
     return false;
 
+  // We only break before r_brace if there was a corresponding break before
+  // the l_brace, which is tracked by BreakBeforeClosingBrace.
+  if (Right.isOneOf(tok::r_brace, tok::r_paren, tok::greater))
+    return false;
+
   // Allow breaking after a trailing 'const', e.g. after a method declaration,
   // unless it is follow by ';', '{' or '='.
   if (Left.is(tok::kw_const) && Left.Parent != NULL &&
@@ -1174,10 +1183,6 @@
   if (Right.is(tok::kw___attribute))
     return true;
 
-  // We only break before r_brace if there was a corresponding break before
-  // the l_brace, which is tracked by BreakBeforeClosingBrace.
-  if (Right.isOneOf(tok::r_brace, tok::r_paren, tok::greater))
-    return false;
   if (Left.is(tok::identifier) && Right.is(tok::string_literal))
     return true;
   return (Left.isBinaryOperator() && Left.isNot(tok::lessless)) ||