[llvm-bugs] [Bug 47097] New: Continuation of long lines aligns with start of line instead of start of instruction

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 10 12:27:17 PDT 2020


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

            Bug ID: 47097
           Summary: Continuation of long lines aligns with start of line
                    instead of start of instruction
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: waris.boonyasiriwat at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 23838
  --> https://bugs.llvm.org/attachment.cgi?id=23838&action=edit
3 files: (1) the dummy test file (2) .clang-format for v10 (3) .clang-format
for v6

Version:
clang-format version 10.0.0-4ubuntu1~18.04.2

Overview:
Continuation of long lines seem to align with the start of line instead of
start of instruction. This behaviour did not exist in clang-format-6.0.

Steps to reproduce:
Run clang-format with ColumnLimit of 120 and ContinuationIndentWidth of 2 on
this snippet (also attached).

void foo()
{
    if (SUCCESS_CONSTANT
        == a_really_really_really_long_function_name(
               reinterpret_cast<uint8_t*>(a_somewhat_long_argument),
a_somewhat_long_argument,
              
reinterpret_cast<uint16_t*>(a_really_really_really_really_really_long_argument),
              
reinterpret_cast<uint32_t*>(a_really_really_really_really_really_long_argument)))
    {
        // do stuff
    }
}

Expected Result (what I got with clang-format-6.0):

void foo()
{
    if (SUCCESS_CONSTANT
        == a_really_really_really_long_function_name(
             reinterpret_cast<uint8_t*>(a_somewhat_long_argument),
a_somewhat_long_argument,
            
reinterpret_cast<uint16_t*>(a_really_really_really_really_really_long_argument),
            
reinterpret_cast<uint32_t*>(a_really_really_really_really_really_long_argument)))
    {
        // do stuff
    }
}


Actual Result (what I got with clang-format-10):

void foo()
{
    if (SUCCESS_CONSTANT
        == a_really_really_really_long_function_name(
          reinterpret_cast<uint8_t*>(a_somewhat_long_argument),
a_somewhat_long_argument,
         
reinterpret_cast<uint16_t*>(a_really_really_really_really_really_long_argument),
         
reinterpret_cast<uint32_t*>(a_really_really_really_really_really_long_argument)))
    {
        // do stuff
    }
}


Notice how the continued line is aligned to the left of the function name. I
tried tweaking many other rules but did not seem to help. This led me to
believe that the alignment reference for long line continuation has been
changed from "start of instruction" to "start of line"

-- 
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/20200810/008b55f4/attachment.html>


More information about the llvm-bugs mailing list