Issue 140664
Summary ReferenceAlignment does NOT work properly (depends on the content of the file being formated)
Labels new issue
Assignees
Reporter huweiATgithub
    The clang-format behaves differently on `Reference Alignment` for different inputs.

```yaml
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 120
SortIncludes: Never
IndentPPDirectives: BeforeHash
InsertNewlineAtEOF: true
ReferenceAlignment: Left
```

## Case 1
When all references are right-aligned initially, it is not being formatted.

input:
```cpp
int f(int &a, int &b) { return a + b; }
```

output:
```cpp
int f(int &a, int &b) { return a + b; }
```


## Case 2
When one reference is left-aligned initially, the other also got formatted.

input:
```cpp
int f(int &a, int& b) { return a + b; }
```
output:
```cpp
int f(int& a, int& b) { return a + b; }
```

## Other info

If use command-line option `--style="{ReferenceAlignment: Left}"`, both cases got formatted correctly.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to