Clang-format: detect unbalanced braces.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits, silvas

Differential Revision: http://llvm-reviews.chandlerc.com/D176

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169518 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 99e5832..425e15b 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -52,8 +52,8 @@
       addUnwrappedLine();
       break;
     case tok::r_brace:
-      // FIXME: We need a test when it has to be "return Error;"
-      return false;
+      // Stray '}' is an error.
+      return true;
     default:
       parseStatement();
       break;
@@ -63,6 +63,7 @@
 }
 
 bool UnwrappedLineParser::parseBlock() {
+  assert(FormatTok.Tok.is(tok::l_brace) && "'{' expected");
   nextToken();
 
   // FIXME: Remove this hack to handle namespaces.