Skip to content

[refactoring] idea: convert a switch statement to an if #34352

@hyp

Description

@hyp
Bugzilla Link 35004
Version trunk
OS All
CC @m4tx

Extended Description

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).

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillaclang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions