[llvm-bugs] [Bug 34543] New: Failed to format nested blocked

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 10 17:30:29 PDT 2017


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

            Bug ID: 34543
           Summary: Failed to format nested blocked
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zonyitoo at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

It works fine if there is only one nested block:

int main()
{
    {
        {
            int a = 0;
        }
    }
}

But if we copy the code in the main function again, like this

int main()
{
    {
        {
            int a = 0;
        }
    }
    {
        {
            int a = 0;
        }
    }
}

clang-format will format the code above like this:

int main()
{
    {{int a = 0;
}
}
{
    {
        int a = 0;
    }
}
}

Configuration for clang-format is:

{
    Language: Cpp,
    BasedOnStyle: Google,

    DerivePointerAlignment: false,
    PointerAlignment: Left,

    BreakBeforeBraces: Allman,

    AlignOperands: true,
    AlignAfterOpenBracket: Align,

    AccessModifierOffset: -4,

    Cpp11BracedListStyle: true,
    NamespaceIndentation: None,
    UseTab: Never,
    TabWidth: 4,
    Standard: Cpp11,
    SpaceBeforeParens: ControlStatements,
    AlwaysBreakTemplateDeclarations: true,

    BinPackArguments: false,
    BinPackParameters: false,

    AlignAfterOpenBracket: true,
    AlignConsecutiveAssignments: true,
    IndentWidth: 4,
    ColumnLimit: 120,
    AllowShortFunctionsOnASingleLine: Inline,
    AllowShortBlocksOnASingleLine: false,

    BreakConstructorInitializersBeforeComma: true,
    BreakBeforeBinaryOperators: NonAssignment,
    BreakBeforeTernaryOperators: true,

    BreakStringLiterals: false,

    SortIncludes: true,
}

-- 
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/20170911/c5a59435/attachment.html>


More information about the llvm-bugs mailing list