[llvm-bugs] [Bug 34043] New: AlignAfterOpenBracket, AllowAllParametersOfDeclarationOnNextLine does not work

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 3 06:06:44 PDT 2017


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

            Bug ID: 34043
           Summary: AlignAfterOpenBracket,
                    AllowAllParametersOfDeclarationOnNextLine does not
                    work
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: acieszkiel at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 18899
  --> https://bugs.llvm.org/attachment.cgi?id=18899&action=edit
Input file

.clang-format:
Language: Cpp
AlignAfterOpenBracket: Align
AllowAllParametersOfDeclarationOnNextLine: true
ColumnLimit: 100
TabWidth: 4
UseTab: Never

Input file:
class MyClass
{
public:
    int method(int parameter1,
               int parameter2,
               int parameter3);
};

int MyClass::method(int parameter1,
                    int parameter2,
                    int parameter3)
{
    return parameter1 + parameter2 + parameter3;
}                         

int function(int parameter1,
             int parameter2,
             int parameter3)
{
    return parameter1 + parameter2 + parameter3;     
}                 

int main()
{
    MyClass m;
    int res1 = m.method(343,
                        444,
                        999);
    int res2 = function(1999,
                        2343,
                        6666);

    return 0;
}

The output:
class MyClass {
public:
  int method(int parameter1, int parameter2, int parameter3);
};

int MyClass::method(int parameter1, int parameter2, int parameter3) {
  return parameter1 + parameter2 + parameter3;
}

int function(int parameter1, int parameter2, int parameter3) {
  return parameter1 + parameter2 + parameter3;
}

int main() {
  MyClass m;
  int res1 = m.method(343, 444, 999);
  int res2 = function(1999, 2343, 6666);

  return 0;
}

Parameters are not aligned and are not allowed to be all in the next lines as
it is in the examples of these options in the specification:

AlignAfterOpenBracket (BracketAlignmentStyle):
BAS_Align (in configuration: Align) Align parameters on the open bracket, e.g.:
someLongFunction(argument1,
                 argument2);

AllowAllParametersOfDeclarationOnNextLine (bool)
Allow putting all parameters of a function declaration onto the next line even
if BinPackParameters is false.

true:                                   false:
myFunction(foo,                 vs.     myFunction(foo, bar, plop);
           bar,
           plop);

They work as expected only if a line exceeds 'ColumnLimit'.

-- 
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/20170803/cff7cdba/attachment.html>


More information about the llvm-bugs mailing list