[llvm-bugs] [Bug 47203] New: clang-format: bad indentation after switch case with braces

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 17 04:44:43 PDT 2020


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

            Bug ID: 47203
           Summary: clang-format: bad indentation after switch case with
                    braces
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hans at chromium.org
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Example:

$ cat /tmp/a.cc
void stuff();
void otherstuff();

#define FALLTHROUGH [[clang::fallthrough]]

void f(int x) {
  switch (x) {
  case 1: {
    stuff();
  }
  FALLTHROUGH
  case 2:
    otherstuff();
  }
}

$ clang-format /tmp/a.cc
void stuff();
void otherstuff();

#define FALLTHROUGH [[clang::fallthrough]]

void f(int x) {
  switch (x) {
  case 1: {
    stuff();
  }
    FALLTHROUGH
  case 2:
    otherstuff();
  }
}



Note how the FALLTHROUGH is more indented after formatting.

Maybe this is reasonable in one sense; the FALLTHROUGH is still "inside" case
1, despite the closing brace. But it also looks a bit strange.

(Originally filed at https://crbug.com/1114925)

-- 
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/20200817/ceec50d1/attachment.html>


More information about the llvm-bugs mailing list