[llvm-bugs] [Bug 48496] New: clang-format: changes when reformatting one line of formatted file

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 13 04:55:15 PST 2020


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

            Bug ID: 48496
           Summary: clang-format: changes when reformatting one line of
                    formatted file
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: barabas.raffai at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Test case is as follows (add to
clang/unittests/Format/FormatTestSelective.cpp):

TEST_F(FormatTestSelective, Bug) {
  Style.AlignConsecutiveDeclarations = true;
  Style.ColumnLimit = 16;

  std::string Code = "int b(void);\n"
                     "int u(int, int);\n"
                     "bool g(void);";

  std::string Full = format(Code, 0, Code.length());
  std::string First = format(Full, 0, 0);
  EXPECT_EQ(Full, First);
}

Test result:
      Expected: Full
      Which is: "int b(void);\nint u(int, int);\nbool g(void);"
To be equal to: First
      Which is: "int  b(void);\nint u(int, int);\nbool g(void);"
With diff:
@@ -1,3 +1,3 @@
-int b(void);
+int  b(void);
 int u(int, int);
 bool g(void);

Expected result:
There are no changes when reformatting the first line.

Another thing to note is that u is not aligned to g. It could be, if the
parameters were moved to the next line. This is what happens when u is changed
to uu, making that line longer than the ColumnLimit.

The bug is present on the main branch at commit
8e6fc1f97eb9a63780158470596ddbec3d0ecd59

-- 
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/20201213/bc789ac6/attachment.html>


More information about the llvm-bugs mailing list