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

            Bug ID: 41159
           Summary: clang-format over-indents with AlignAfterOpenBracket
                    and AlignAfterOpenBracket=DontAlign
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangb...@nondot.org
          Reporter: john.j.be...@gmail.com
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@lists.llvm.org

Using the following code:

static LIB_TEXT* loadText( std::unique_ptr<LIB_PART>& aPart, LINE_READER&
aReader, int aMajorVersion );
static LIB_RECTANGLELIB_RECTANGLE* loadRectangle( std::unique_ptr<LIB_PART>&
aPart );

And this config:

BasedOnStyle: llvm
ContinuationIndentWidth: 8
AlignAfterOpenBracket: DontAlign
AlignConsecutiveDeclarations: true

Produces:

static LIB_TEXT *                  loadText( std::unique_ptr<LIB_PART> &aPart,
                          LINE_READER &aReader, int aMajorVersion );
static LIB_RECTANGLELIB_RECTANGLE *loadRectangle(
        std::unique_ptr<LIB_PART> &aPart );

Where line 2 is indented by much more than the continuation indent.

Removing AlignConsecutiveDeclarations is OK:

static LIB_TEXT *loadText(std::unique_ptr<LIB_PART> &aPart,
        LINE_READER &aReader, int aMajorVersion);
static LIB_RECTANGLELIB_RECTANGLE *loadRectangle(
        std::unique_ptr<LIB_PART> &aPart);

And AlignAfterOpenBracket=Align is OK:

static LIB_TEXT *loadText(std::unique_ptr<LIB_PART> &aPart,
                          LINE_READER &aReader, int aMajorVersion);
static LIB_RECTANGLELIB_RECTANGLE *
loadRectangle(std::unique_ptr<LIB_PART> &aPart);

This seems like a similar case to https://bugs.llvm.org/show_bug.cgi?id=33546
where there are not enough spaces with AlignConsecutiveAssignments=true and
AlignAfterOpenBracket=Align

----

Easy one-line repro:

echo "static LIB_TEXT* loadText( std::unique_ptr<LIB_PART>& aPart, LINE_READER&
aReader, int aMajorVersion); static LIB_RECTANGLELIB_RECTANGLE* loadRectangle(
std::unique_ptr<LIB_PART>& aPart );" | clang-format -style="{BasedOnStyle:
llvm, ContinuationIndentWidth: 8, AlignAfterOpenBracket: DontAlign,
AlignConsecutiveDeclarations: true}"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to