Improve clang-format's error recovery.

If a "}" is found inside parenthesis, this is probably a case of
missing parenthesis. This enables continuing to format after stuff code
like:

class A {
  void f(
};
..

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183009 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 618f54a..933da66 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -45,6 +45,7 @@
     else
       Line.MustBeDeclaration = true;
   }
+
 private:
   UnwrappedLine &Line;
   std::vector<bool> &Stack;
@@ -81,9 +82,7 @@
     return Token;
   }
 
-  virtual unsigned getPosition() {
-    return PreviousTokenSource->getPosition();
-  }
+  virtual unsigned getPosition() { return PreviousTokenSource->getPosition(); }
 
   virtual FormatToken *setPosition(unsigned Position) {
     Token = PreviousTokenSource->setPosition(Position);
@@ -279,7 +278,7 @@
     case tok::kw_for:
     case tok::kw_switch:
     case tok::kw_try:
-      if (!LBraceStack.empty()) 
+      if (!LBraceStack.empty())
         LBraces[LBraceStack.back()] = BS_Block;
       break;
     default:
@@ -386,9 +385,7 @@
   parsePPUnknown();
 }
 
-void UnwrappedLineParser::parsePPElIf() {
-  parsePPElse();
-}
+void UnwrappedLineParser::parsePPElIf() { parsePPElse(); }
 
 void UnwrappedLineParser::parsePPEndIf() {
   if (!PPStack.empty())
@@ -700,15 +697,21 @@
     case tok::r_paren:
       nextToken();
       return;
+    case tok::r_brace:
+      // A "}" inside parenthesis is an error if there wasn't a matching "{".
+      return;
     case tok::l_brace: {
       if (!tryToParseBracedList()) {
         nextToken();
-        ScopedLineState LineState(*this);
-        ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
-                                                /*MustBeDeclaration=*/ false);
-        Line->Level += 1;
-        parseLevel(/*HasOpeningBrace=*/ true);
-        Line->Level -= 1;
+        {
+          ScopedLineState LineState(*this);
+          ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
+                                                  /*MustBeDeclaration=*/ false);
+          Line->Level += 1;
+          parseLevel(/*HasOpeningBrace=*/ true);
+          Line->Level -= 1;
+        }
+        nextToken();
       }
       break;
     }