| Issue |
167357
|
| Summary |
Clang-format : Allow multiple lines for chained ternary operators
|
| Labels |
clang-format
|
| Assignees |
|
| Reporter |
theyyg
|
This is a feature proposal for clang-format.
I would like to have clang-format be able to allow chained ternary operators in a multiline format. This format is incredibly useful for conditional assignments like checking for the bounds of a variable.
Current Behavior:
```
int bounded = (value > max) ? max : (value < min) ? min : value;
```
Preferred:
```
int bounded = (value > max) ? max :
(value < min) ? min :
value;
```
Acceptable:
```
int bounded = (value > max) ? max :
(value < min) ? min : value;
```
This behavior would require adding a line break after the colon of a ternary operator if the right-hand operand is another ternary operator. If this condition is met, I'd prefer to have a line break after all colons in the chain which would include the final value. I realize that would complicate the rule, and it would be acceptable if it was not a part of the feature.
Thank you for your consideration!
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs