<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 - Nested Scope formatting failure"
href="https://bugs.llvm.org/show_bug.cgi?id=39504">39504</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Nested Scope formatting failure
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>ashley.harris@maptek.com.au
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21060" name="attach_21060" title="Clangformat file">attachment 21060</a> <a href="attachment.cgi?id=21060&action=edit" title="Clangformat file">[details]</a></span>
Clangformat file
The following code is a simplified version of a thousand line piece of old C++
code:
int main()
{
{ // Do group of things 1
{ // Do group of things 1 - A
Thing1A1();
Thing1A2();
}
NotUsed();
{ // Do group of things 1 - B
Thing1B1();
Thing1B2();
}
}
{ // Do group of things 2
{ // Do group of things 2 - A
Thing2A1();
Thing2A2();
}
{ // Do group of things 2 - B
Thing2B1();
Thing2B2();
}
}
}
It formats to how it's displayed, which is correct for my projects clang-format
file. However, comment out or remove the "NotUsed()" method, and it then
formats like so:
int main()
{
{// Do group of things 1
{// Do group of things 1 - A
Thing1A1();
Thing1A2();
}
// NotUsed();
{ // Do group of things 1 - B
Thing1B1();
Thing1B2();
}
}
{ // Do group of things 2
{ // Do group of things 2 - A
Thing2A1();
Thing2A2();
}
{ // Do group of things 2 - B
Thing2B1();
Thing2B2();
}
}
}
Which is considerably wrong. The scoping has been used to group like regions
together in existing code (not how I would've done it, but still valid I
guess). Putting a "(void)nullptr;" where the NotUsed() statement was fixes the
formatting for a short-term workaround.</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>