Index: include/clang/Format/Format.h
===================================================================
--- include/clang/Format/Format.h	(revision 187344)
+++ include/clang/Format/Format.h	(working copy)
@@ -77,6 +77,12 @@
   /// Switch statement body is always indented one level more than case labels.
   bool IndentCaseLabels;
 
+  /// \brief Indent the content of namespaces by one level.
+  ///
+  /// When false, use the same indentation level as outside block (file or
+  /// namespace).
+  bool IndentInNamespaces;
+
   /// \brief The number of spaces to before trailing line comments.
   unsigned SpacesBeforeTrailingComments;
 
@@ -196,6 +202,7 @@
            ExperimentalAutoDetectBinPacking ==
                R.ExperimentalAutoDetectBinPacking &&
            IndentCaseLabels == R.IndentCaseLabels &&
+           IndentInNamespaces == R.IndentInNamespaces &&
            IndentWidth == R.IndentWidth &&
            MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep &&
            ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList &&
Index: lib/Format/Format.cpp
===================================================================
--- lib/Format/Format.cpp	(revision 187344)
+++ lib/Format/Format.cpp	(working copy)
@@ -101,6 +101,7 @@
     IO.mapOptional("ExperimentalAutoDetectBinPacking",
                    Style.ExperimentalAutoDetectBinPacking);
     IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
+    IO.mapOptional("IndentInNamespaces", Style.IndentInNamespaces);
     IO.mapOptional("MaxEmptyLinesToKeep", Style.MaxEmptyLinesToKeep);
     IO.mapOptional("ObjCSpaceBeforeProtocolList",
                    Style.ObjCSpaceBeforeProtocolList);
@@ -156,6 +157,7 @@
   LLVMStyle.ExperimentalAutoDetectBinPacking = false;
   LLVMStyle.IndentCaseLabels = false;
   LLVMStyle.IndentFunctionDeclarationAfterType = false;
+  LLVMStyle.IndentInNamespaces = false;
   LLVMStyle.IndentWidth = 2;
   LLVMStyle.MaxEmptyLinesToKeep = 1;
   LLVMStyle.ObjCSpaceBeforeProtocolList = true;
@@ -190,6 +192,7 @@
   GoogleStyle.ExperimentalAutoDetectBinPacking = false;
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.IndentFunctionDeclarationAfterType = true;
+  GoogleStyle.IndentInNamespaces = false;
   GoogleStyle.IndentWidth = 2;
   GoogleStyle.MaxEmptyLinesToKeep = 1;
   GoogleStyle.ObjCSpaceBeforeProtocolList = false;
@@ -332,7 +335,7 @@
       ColumnLimit = getColumnLimit();
     if (Line.Last->TotalLength <= ColumnLimit - FirstIndent) {
       while (State.NextToken != NULL) {
-        addTokenToState(false, false, State);
+        addTokenToState(/*Newline=*/false, /*DryRun=*/false, State);
       }
     }
 
@@ -464,7 +467,7 @@
     }
   };
 
-  /// \brief The current state when indenting a unwrapped line.
+  /// \brief The current state when indenting an unwrapped line.
   ///
   /// As the indenting tries different combinations this is copied by value.
   struct LineState {
@@ -798,7 +801,7 @@
       //       Next(...)
       //       ^ line up here.
       if (!Style.BreakConstructorInitializersBeforeComma)
-        State.Stack.back().Indent = State.Column + 2;
+      State.Stack.back().Indent = State.Column + 2;
       if (Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
         State.Stack.back().AvoidBinPacking = true;
       State.Stack.back().BreakBeforeParameter = false;
@@ -1231,32 +1234,32 @@
       return true;
 
     if (!Style.BreakBeforeBinaryOperators) {
-      // If we need to break somewhere inside the LHS of a binary expression, we
-      // should also break after the operator. Otherwise, the formatting would
-      // hide the operator precedence, e.g. in:
-      //   if (aaaaaaaaaaaaaa ==
-      //           bbbbbbbbbbbbbb && c) {..
-      // For comparisons, we only apply this rule, if the LHS is a binary
-      // expression itself as otherwise, the line breaks seem superfluous.
-      // We need special cases for ">>" which we have split into two ">" while
-      // lexing in order to make template parsing easier.
+    // If we need to break somewhere inside the LHS of a binary expression, we
+    // should also break after the operator. Otherwise, the formatting would
+    // hide the operator precedence, e.g. in:
+    //   if (aaaaaaaaaaaaaa ==
+    //           bbbbbbbbbbbbbb && c) {..
+    // For comparisons, we only apply this rule, if the LHS is a binary
+    // expression itself as otherwise, the line breaks seem superfluous.
+    // We need special cases for ">>" which we have split into two ">" while
+    // lexing in order to make template parsing easier.
       //
       // FIXME: We'll need something similar for styles that break before binary
       // operators.
-      bool IsComparison = (Previous.getPrecedence() == prec::Relational ||
-                           Previous.getPrecedence() == prec::Equality) &&
+    bool IsComparison = (Previous.getPrecedence() == prec::Relational ||
+                         Previous.getPrecedence() == prec::Equality) &&
                           Previous.Previous && Previous.Previous->Type !=
                                                    TT_BinaryOperator; // For >>.
-      bool LHSIsBinaryExpr =
-          Previous.Previous && Previous.Previous->FakeRParens > 0;
-      if (Previous.Type == TT_BinaryOperator &&
-          (!IsComparison || LHSIsBinaryExpr) &&
-          Current.Type != TT_BinaryOperator && // For >>.
-          !Current.isTrailingComment() &&
-          !Previous.isOneOf(tok::lessless, tok::question) &&
-          Previous.getPrecedence() != prec::Assignment &&
-          State.Stack.back().BreakBeforeParameter)
-        return true;
+    bool LHSIsBinaryExpr =
+        Previous.Previous && Previous.Previous->FakeRParens > 0;
+    if (Previous.Type == TT_BinaryOperator &&
+        (!IsComparison || LHSIsBinaryExpr) &&
+        Current.Type != TT_BinaryOperator && // For >>.
+        !Current.isTrailingComment() &&
+        !Previous.isOneOf(tok::lessless, tok::question) &&
+        Previous.getPrecedence() != prec::Assignment &&
+        State.Stack.back().BreakBeforeParameter)
+      return true;
     }
 
     // Same as above, but for the first "<<" operator.
Index: lib/Format/UnwrappedLineParser.cpp
===================================================================
--- lib/Format/UnwrappedLineParser.cpp	(revision 187344)
+++ lib/Format/UnwrappedLineParser.cpp	(working copy)
@@ -794,7 +794,8 @@
     if (Style.BreakBeforeBraces == FormatStyle::BS_Linux)
       addUnwrappedLine();
 
-    parseBlock(/*MustBeDeclaration=*/true, 0);
+    parseBlock(/*MustBeDeclaration=*/true,
+               /*AddLevels=*/Style.IndentInNamespaces);
     // 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))
Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp	(revision 187344)
+++ unittests/Format/FormatTest.cpp	(working copy)
@@ -239,6 +239,50 @@
                    "}  // namespace"));
 }
 
+TEST_F(FormatTest, IndentsInNamespacesLLVM) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentInNamespaces = true;
+  EXPECT_EQ("namespace {\n"
+            "  int i;\n"
+            "\n"
+            "} // namespace",
+            format("namespace {\n"
+                   "int i;\n"
+                   "\n"
+                   "} // namespace",
+                   Style));
+
+  EXPECT_EQ("namespace out {\n"
+            "  namespace in {\n"
+            "    int i;\n"
+            "\n"
+            "  } // namespace\n"
+            "} // namespace",
+            format("namespace out {\n"
+                   "namespace in {\n"
+                   "int i;\n"
+                   "\n"
+                   "} // namespace\n"
+                   "} // namespace",
+                   Style));
+}
+
+TEST_F(FormatTest, IndentsInNamespacesBSLinux) {
+  FormatStyle Style = getWebKitStyle();
+  Style.IndentInNamespaces = true;
+  Style.BreakBeforeBraces = FormatStyle::BS_Linux;
+  EXPECT_EQ("namespace\n"
+            "{\n"
+            "    int i;\n"
+            "\n"
+            "} // namespace",
+            format("namespace {\n"
+                   "int i;\n"
+                   "\n"
+                   "}  // namespace",
+                   Style));
+}
+
 TEST_F(FormatTest, ReformatsMovedLines) {
   EXPECT_EQ(
       "template <typename T> T *getFETokenInfo() const {\n"
@@ -842,10 +886,10 @@
                    "           1.1.1. to keep the formatting.\n"
                    "   */"));
   EXPECT_EQ("/*\n"
-            "Don't try to outdent if there's not enough inentation.\n"
+            "Don't try to outdent if there's not enough indentation.\n"
             "*/",
             format("  /*\n"
-                   " Don't try to outdent if there's not enough inentation.\n"
+                   " Don't try to outdent if there's not enough indentation.\n"
                    " */"));
 
   EXPECT_EQ("int i; /* Comment with empty...\n"
@@ -5449,6 +5493,7 @@
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
   CHECK_PARSE_BOOL(DerivePointerBinding);
   CHECK_PARSE_BOOL(IndentCaseLabels);
+  CHECK_PARSE_BOOL(IndentInNamespaces);
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(PointerBindsToType);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
