[llvm-bugs] [Bug 48231] New: clang-format gets confused by nested blocks

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 19 10:11:31 PST 2020


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

            Bug ID: 48231
           Summary: clang-format gets confused by nested blocks
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: officesamurai at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 24185
  --> https://bugs.llvm.org/attachment.cgi?id=24185&action=edit
The code in question

As a result, the blocks are formatted incorrectly and the namespace-closing
comments are put in wrong places.

--- nested_blocks.cpp --
namespace A
{
namespace B
{
namespace C
{
void foo()
{
    {
        {
            bar();
        }
    }
    {
        baz();
    }
}

}
}
}
---

---
$ /home/brd/soft/llvm-11.0.0/bin/clang-format --version
clang-format version 11.0.0

$ cat nested_blocks.cpp | /home/brd/soft/llvm-11.0.0/bin/clang-format
--style=LLVM
namespace A {
namespace B {
namespace C {
void foo() { {{bar(); }
} // namespace C
{ baz(); }
} // namespace B

} // namespace A
}
}
---

-- 
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/20201119/09fff29e/attachment.html>


More information about the llvm-bugs mailing list