Issue |
156210
|
Summary |
[clang-format][feature request] Ternary support?
|
Labels |
clang-format
|
Assignees |
|
Reporter |
DiogoHSS
|
When using clang-format I found that the lacking of ternary operator styling options kinda of a bummer.
Ternary operators just format as the following code:
```cpp
bool test = 10 > 6 ? true : false;
```
Support for the following sub-options under a top level options like **Break Ternary Operator** would be appreaciated
Break Before Operators
```cpp
bool test = 10 > 6
? true
: false;
```
Break Before Condition Operator Only
```cpp
bool test = 10 > 6
? true : false;
```
Break After Operators
```cpp
bool test = 10 > 6 ?
true :
false;
```
Break After Condition Operator Only
```cpp
bool test = 10 > 6 ?
true : false;
```
**New Option**
Break Semicolon when Enable Ternary Operator Break is true
```cpp
bool test = 10 > 6 ?
true :
false
;
```
**New Option**
Wrap Ternary In Parenthesis, no idea about the value names for the following options
```cpp
bool test = (10 > 6 ?
true :
false);
```
```cpp
bool test =
(10 > 6
? true
: false);
```
````cpp
bool test = (
10 > 6
? true
: false
);
```
Also, create a AlignTernaryOperands aside from AlignOperands to achieve:
```cpp
bool test =
10 > 6
? true
: false;
}
```
This is the styling I go for personally
```cpp
bool test = (
10 > 6
? (
1 >= 0
? true
: false
)
: false
);
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs