[llvm-bugs] [Bug 39504] New: Nested Scope formatting failure
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 30 21:59:42 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39504
Bug ID: 39504
Summary: Nested Scope formatting failure
Product: clang
Version: 7.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: ashley.harris at maptek.com.au
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Created attachment 21060
--> https://bugs.llvm.org/attachment.cgi?id=21060&action=edit
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.
--
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/20181031/861ea855/attachment.html>
More information about the llvm-bugs
mailing list