[llvm-bugs] [Bug 37443] New: clang-format doesn't indent {} block when format is set to llvm.

via llvm-bugs llvm-bugs at lists.llvm.org
Sun May 13 18:41:03 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37443

            Bug ID: 37443
           Summary: clang-format doesn't indent {} block when format is
                    set to llvm.
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mirai2045 at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

This occurs clang-format version 3.8 and upper.
When .clang-format is
BasedOnStyle: LLVM
Standard: Cpp11

ColumnLimit: 0
IndentWidth: 4
UseTab: Never
MaxEmptyLinesToKeep: 2

BreakBeforeBinaryOperators: All
BreakBeforeBraces: Linux
AlignAfterOpenBracket: false
SpaceBeforeParens: ControlStatements
AlwaysBreakTemplateDeclarations: true
AlignEscapedNewlinesLeft: true
PointerAlignment: Left
AccessModifierOffset: -4
AllowShortFunctionsOnASingleLine: All
SortIncludes: false
SortUsingDeclarations: false

SpacesBeforeTrailingComments: 2
CommentPragmas: '[!\*]'

and the source file is 


void sayHello()
{
    {// Hoge and Fuga
        {// Hoge
            Hoge::sayHoge();
        }
        {  // Fuga
            Fuga::sayFuga();
        }
    }
    {  // Foo and Bar
        {  // Foo
            Foo::sayFoo();
        }
        {  // Bar
            Bar::sayBar();
        }
    }
}

int main()
{
    sayHello();
}

then clang-format-3.8 or upper version cannot indent the source properly.

Which is, 
vvoid sayHello()
{
    {    // Hoge and Fuga
        {// Hoge
            Hoge::sayHoge();
}
{  // Fuga
    Fuga::sayFuga();
}
}
{      // Foo and Bar
    {  // Foo
        Foo::sayFoo();
    }
    {  // Bar
        Bar::sayBar();
    }
}
}

int main()
{
    sayHello();
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180514/edcff5e3/attachment.html>


More information about the llvm-bugs mailing list