Error recovery part 2

Summary: Adds recovery for structural errors in clang-format.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, silvas

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169286 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 888f1c9..e1972e9 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -32,12 +32,13 @@
   Lex.SetKeepWhitespaceMode(true);
 }
 
-void UnwrappedLineParser::parse() {
+bool UnwrappedLineParser::parse() {
   parseToken();
-  parseLevel();
+  return parseLevel();
 }
 
-void UnwrappedLineParser::parseLevel() {
+bool UnwrappedLineParser::parseLevel() {
+  bool Error = false;
   do {
     switch (FormatTok.Tok.getKind()) {
     case tok::hash:
@@ -47,19 +48,20 @@
       parseComment();
       break;
     case tok::l_brace:
-      parseBlock();
+      Error |= parseBlock();
       addUnwrappedLine();
       break;
     case tok::r_brace:
-      return;
+      return false;
     default:
       parseStatement();
       break;
     }
   } while (!eof());
+  return Error;
 }
 
-void UnwrappedLineParser::parseBlock() {
+bool UnwrappedLineParser::parseBlock() {
   nextToken();
 
   // FIXME: Remove this hack to handle namespaces.
@@ -74,11 +76,12 @@
     --Line.Level;
   // FIXME: Add error handling.
   if (!FormatTok.Tok.is(tok::r_brace))
-    return;
+    return true;
 
   nextToken();
   if (FormatTok.Tok.is(tok::semi))
     nextToken();
+  return false;
 }
 
 void UnwrappedLineParser::parsePPDirective() {