Issue 164866
Summary clang-format adds a space between the parameter type and `&` under google style guide
Labels clang-format
Assignees
Reporter PiJoules
    Here's a regression test demonstrating this:

```
// RUN: grep -Ev "// *[A-Z-]+" %s | clang-format --style='{BasedOnStyle: google, ColumnLimit: 0}' | FileCheck %s -strict-whitespace

// CHECK: ::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication& other) noexcept {
::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication& other) noexcept {
  storage_ = other.CloneStorage_();
  return *this;
}
```

which fails with

```
# | /usr/local/google/home/leonardchan/llvm-projects/llvm-project-1/clang/test/Format/regression-test.cpp:3:11: error: CHECK: expected string not found in input
# | // CHECK: ::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication& other) noexcept {
# |           ^
# | <stdin>:1:1: note: scanning from here
# | 
# | ^
# | <stdin>:2:1: note: possible intended match here
# | ::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication & other) noexcept {
# | ^
# | 
```

The google style guide does not permit a space before the `&` as per https://google.github.io/styleguide/cppguide.html#Pointer_and_Reference_Expressions.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to