]> granicus.if.org Git - clang/commitdiff
clang-format: Fix bug concerning the alignment of "}".
authorDaniel Jasper <djasper@google.com>
Thu, 11 Jul 2013 21:27:40 +0000 (21:27 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 11 Jul 2013 21:27:40 +0000 (21:27 +0000)
Before:
    int i;  // indented 2 space more than clang-format would use.
    SomeReturnType  // clang-format invoked on this line.
    SomeFunctionMakingLBraceEndInColumn80() {
  }  // This is the indent clang-format would prefer.

After:
    int i;  // indented 2 space more than clang-format would use.
    SomeReturnType  // clang-format invoked on this line.
    SomeFunctionMakingLBraceEndInColumn80() {
    }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186120 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp
unittests/Format/FormatTest.cpp

index 680bb1301317915f85789a3ccd5527e3e3a93314..a98d565caa4a1f9371cca6e3c0606409635f0617 100644 (file)
@@ -536,7 +536,7 @@ private:
         if (Current.BlockKind == BK_BracedInit)
           State.Column = State.Stack[State.Stack.size() - 2].LastSpace;
         else
-          State.Column = Line.Level * Style.IndentWidth;
+          State.Column = FirstIndent;
       } else if (Current.is(tok::string_literal) &&
                  State.StartOfStringLiteral != 0) {
         State.Column = State.StartOfStringLiteral;
index ae4d9f5c0d9b972d96004a1324e079caf92cf33b..6e53f92e5a84514932053d8da4493ce0338bfcb9 100644 (file)
@@ -4810,6 +4810,13 @@ TEST_F(FormatTest, ReformatRegionAdjustsIndent) {
                    "       // line 2\n"
                    "  int b;",
                    35, 0, getLLVMStyle()));
+  EXPECT_EQ("  int a;\n"
+            "  void\n"
+            "  ffffff() {\n"
+            "  }",
+            format("  int a;\n"
+                   "void ffffff() {}",
+                   11, 0, getLLVMStyleWithColumns(11)));
 }
 
 TEST_F(FormatTest, BreakStringLiterals) {