llvm-project
llvm-project copied to clipboard
clang-format: Add AlignConsecutiveShortCaseLabels
I suggest adding an option to align consecutive short case labels.
I have code like this:
constexpr string_view describe(log::level level)
{
switch (level) {
case log::info: return "info: ";
case log::warning: return "warning: ";
case log::error: return "error: ";
case log::critical: return "critical: ";
default: return "";
};
}
clang-format formats removes all alignment like this:
constexpr string_view describe(log::level level)
{
switch (level) {
case log::info: return "info: ";
case log::warning: return "warning: ";
case log::error: return "error: ";
case log::critical: return "critical: ";
default: return "";
};
}
I want to keep the alignment.
@llvm/issue-subscribers-clang-format
This desired feature came up in my attempt to introduce use of clang-format to my codebase at work. I would be willing to work on this and make a patch as long as the consensus is that it would be a desirable feature (I assume by this still being open, that's the case?).
https://reviews.llvm.org/D151761