Much semicolon after namespaces.

We now leave the semicolon in the line of the closing brace in:
namespace {
...
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174514 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index f79cc71..5af60a4 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -505,6 +505,10 @@
     nextToken();
   if (FormatTok.Tok.is(tok::l_brace)) {
     parseBlock(/*MustBeDeclaration=*/ true, 0);
+    // Munch the semicolon after a namespace. This is more common than one would
+    // think. Puttin the semicolon into its own line is very ugly.
+    if (FormatTok.Tok.is(tok::semi))
+      nextToken();
     addUnwrappedLine();
   }
   // FIXME: Add error handling.
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index c2e845b..4dc6ea7 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -617,6 +617,15 @@
   verifyFormat("using namespace some_namespace;\n"
                "class A {\n};\n"
                "void f() { f(); }");
+
+  // This code is more common than we thought; if we
+  // layout this correctly the semicolon will go into
+  // its own line, which is undesireable.
+  verifyFormat("namespace {\n};");
+  verifyFormat("namespace {\n"
+               "class A {\n"
+               "};\n"
+               "};");
 }
 
 TEST_F(FormatTest, FormatsExternC) {