[llvm-bugs] [Bug 35004] New: [refactoring] idea: convert a switch statement to an if

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 19 12:07:26 PDT 2017


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

            Bug ID: 35004
           Summary: [refactoring] idea: convert a switch statement to an
                    if
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arphaman at gmail.com
                CC: klimek at google.com, llvm-bugs at lists.llvm.org

This is a possible idea for a new refactoring action for clang-refactor &
editors that support integration with Clang's refactoring engine.

This idea suggests adding a refactoring that can convert a switch statement
into an if statement. For example, this statement:

  switch (x) {
  case 0:
    foo();
    break;
  case 1:
    bar();
    break;
  }

Can become:

    if (x == 1) {
        foo();
    } else if (x == 2) {
        bar();
    }

(Note: I'm intending to add an operation that implements the reverse, i.e.
convert if to switch).

-- 
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/20171019/02502060/attachment.html>


More information about the llvm-bugs mailing list