[llvm-bugs] [Bug 50525] New: clang-format: doesn't handle AlignConsecutiveAssignments correctly in some situation.

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 29 07:07:30 PDT 2021


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

            Bug ID: 50525
           Summary: clang-format: doesn't handle
                    AlignConsecutiveAssignments correctly in some
                    situation.
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: darwin.xu at icloud.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 24899
  --> https://bugs.llvm.org/attachment.cgi?id=24899&action=edit
clang-format config file

The config file is attached.

---- The expected code is: ----
01: static NTSTATUS stg(PLW_STREAM Stream, int identity)
02: {
03:     NTSTATUS             status;
04:     BYTE                 payload[256] = {'l', 'h', 'o', 't', 's', 'e'};
05:     struct dm_rpc_header header       = {.drh_magic        = DRH_MAGIC,
06:                                          .drh_op_code      = RPC_OP_ECHO,
07:                                          .drh_payload_size =
sizeof(payload),
08:                                          .drh_body_size    =
sizeof(payload),
09:                                          .drh_request_id   = 1};
10:     header.drh_version                = identity;
---- The output of clang-format is: ----
01: static NTSTATUS stg(PLW_STREAM Stream, int identity)
02: {
03:     NTSTATUS             status;
04:     BYTE                 payload[256] = {'l', 'h', 'o', 't', 's', 'e'};
05:     struct dm_rpc_header header       = {.drh_magic        = DRH_MAGIC,
06:                                    .drh_op_code      = RPC_OP_ECHO,
07:                                    .drh_payload_size = sizeof(payload),
08:                                    .drh_body_size    = sizeof(payload),
09:                                    .drh_request_id   = 1};
10:     header.drh_version                = identity;

It seems that clang-format assumes that line 05 isn't align with the previous
line is the reason line 06 is like this.
05:     struct dm_rpc_header header = {.drh_magic        = DRH_MAGIC,
06:                                    .drh_op_code      = RPC_OP_ECHO,

-- 
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/20210529/143a61ae/attachment.html>


More information about the llvm-bugs mailing list