[llvm-bugs] [Bug 44481] New: Please add an option to treat for-blocks as blocks. (Regarding '{'-attaching.)

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 7 09:08:24 PST 2020


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

            Bug ID: 44481
           Summary: Please add an option to treat for-blocks as blocks.
                    (Regarding '{'-attaching.)
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jzpigtc4zsi at 0box.eu
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

$ clang-format -version
clang-format version 8.0.0-3 (tags/RELEASE_800/final)

$ cat k.c
   {
      if (A) {
         blah(1);
      } else if (B) {
         blah(2);
      } else for (;;) {
         blah(3);
      }
   }

clang-format does this:

$ clang-format -style=file k.c
{
   if (A) {
      blah(1);
   } else if (B) {
      blah(2);
   } else
      for (;;) {
         blah(3);
      }
}

I would prefer doing (via an option) this:

{
   if (A) {
      blah(1);
   } else if (B) {
      blah(2);
   } else for (;;) {
      blah(3);
   }
}

I have not found yet any option to achieve this.

My example is the for-block, but there are (at least two) similar block
constructs: while-block and do(-while)-block. Do not forget them (for
consistency).

-- 
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/20200107/9772ad5b/attachment.html>


More information about the llvm-bugs mailing list