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: unassignedclangb...@nondot.org
Reporter: ashley.har...@maptek.com.au
CC: djas...@google.com, kli...@google.com,
llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs