Skip to content

incorrect indentation with clang-format's AlignConsecutiveAssignments: true #55161

Closed
@zmodem

Description

Consider:

$ cat /tmp/a.cc
#if A
bool thisisalongvariablename = true;
#else
bool thisisalongvariablename = false;
#endif

#if B
bool shortervarname = true;
#else
bool shortervarname = false;
#endif

void foo() {
#if C
#else
  if (bar) {
    baz();
  }
#endif
}

$ build.release/bin/clang-format -style="{AlignConsecutiveAssignments: true}" /tmp/a.cc 
#if A
bool thisisalongvariablename = true;
#else
bool thisisalongvariablename = false;
#endif

#if B
bool shortervarname = true;
#else
bool shortervarname          = false;
#endif

void foo() {
#if C
#else
  if (bar) {
             baz();
  }
#endif
}

Note that the second assignment to shortervarname gets aligned, but not the first one.
And the indentation for baz() is wrong.
The issues seem to be connected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorclang-format

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions