<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-format: changes when reformatting one line of formatted file"
href="https://bugs.llvm.org/show_bug.cgi?id=48496">48496</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-format: changes when reformatting one line of formatted file
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>barabas.raffai@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>