<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/100729>100729</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Inconsistent amperand and pointer spacing with nested/interface scope
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          vesterij
      </td>
    </tr>
</table>

<pre>
    clang-format version 18.1.8 and default config

Formatting following code will replicate the issue.

```cpp
#pragma once

namespace Helper
{
        HRESULT GetSomething(
                bool& bOnline,
                long& lMaxCount,
                CMyClass& myclass,
                CPointerToSomething* psomething,
                std::string& szFilter
        );
        
        // Ok.
        HRESULT GetSomethingElse(
                CMyClass& myclass,
                CPointerToSomething* psomething,
                long lId,
                bool& bAvailable,
                CState& state
                CPointerToSomething* psomethingElse,
        );

        // interface
        interface MyInterface
        {
                HRESULT GetSomething(
                        bool& bOnline,
                        long& lMaxCount,
                        CMyClass& myclass,
                        CPointerToSomething* psomething,
                        std::string& szFilter
                );
                
                // Wrong.
                HRESULT GetSomethingElse(
                        CMyClass& myclass,
                        CPointerToSomething* psomething,
                        long lId,
                        bool& bAvailable,
                        CState& state
                        CPointerToSomething* psomethingElse,
                );
        
        };
        
        // Scope
        {
                HRESULT GetSomething(
                        bool& bOnline,
                        long& lMaxCount,
                        CMyClass& myclass,
                        CPointerToSomething* psomething,
                        std::string& szFilter
                );
                
                // Wrong.
                HRESULT GetSomethingElse(
                        CMyClass& myclass,
                        CPointerToSomething* psomething,
                        long lId,
                        bool& bAvailable,
                        CState& state
                        CPointerToSomething* psomethingElse,
                );
        
        }
}

```

Clang-format with default config will change a lot but the probem is that when references or pointers to function parameters are first parameters there is an extra space.

You get:
`CMyClass & myclass` and `CPointerToSomething * psomething` 
Instead of:
`CMyClass& myclass` and `CPointerToSomething* psomething` 

But this is only if there is a nested scope (like with interface) and object is first paramater.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVlFv2zYQ_jX0yyGCRCW29aAHx6nXAAs6LB2GPVLUSWJLkQJ5cur9-oGSY8tuknrF1qcCtizf8Y687z7pPuG9qg1izm5u2c3dTPTUWJdv0RM69WlW2HKXSy1MfVVZ1wqCLTqvrIFkGSXREoQpocRK9JpAWlOpmsV3LF6N180QQ8rUUFmt7VO4k7ZEeFJag8NOKykIgRoE5X2P0TSczePxI7tub-Fp50TdCrBG4nStES36TkiE96g7dHvf4vZ5Ufb-93ePf_z6EX5BerQtUqNMzfjy4GdxVlirGZ9D8cFoZZDx9dSrbQiYg34QX9a2N3TmXz_s1lp4H9a0Oznenq74zSpD6D7ayQlW0Pnjv5P1nkqWrli68uTUuLn_e6M0HeqLM8Yzlt5Oog72DeMb-PA5ehOBd9rjGQr_fR0BOdD35Zn5APdqK5QWhT5HfP1IgnAoe7j5N0cYC1u_gtMpSEOmShwZlR0s8LC7_8o7pdVlzPomuS7g10Wt-Y7uXEq0F7iWnXoHMP901tTRt_B5gXf_Y32vEPASDr5Nw-9i4hsP7eLurYf5UdruJwt_svAHsHA_Pu9enMdT43qqDp4UNWd6YBz1shGmRhCgLUHR0zDxO2cLbEF5oCYEN2jAYYUOjUQP1kE3FuWBLFS9kRSkRyecaHEwC4dQKedpaqQGXZATIAzgF3ICBmFwIi3-sj3USIFuz6U9dx2mbZ_Hg8QJ7q8BhrOGz2MYs90bTyhKsNVLG1yc_7X04_V2QFH5UKk1egeqmpQOJmi4Enx4ZQDjS60-49if47Tj2bC7LT6hpBA2wVIQuj1kszJPyyzNxAzzZMGTLOPLm2zW5JiV8xtRIl-maZJhEpcyTqpMYCkLLuPFTOU85tfxgs-ThMc3yyieY5UukiTjcpEm6TW7jrEVSkdab9vIuno2yMA8ieMFz2ZaFKj9oE45N_g0ikTGeRCrLg9BV0Vfe3Yda-XJH9OQIo35vZHWeOUJDYFoO3Sh3vDdM2ugRmjlgMyIGeOb4_gf8Jv1TucNUedDP4cXTK2o6YtI2pbxTdh1_3PVORvQDEnCWT3jm30x25z_EwAA__-of1vt">