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

    <tr>
        <th>Summary</th>
        <td>
            clang-format: Incorrect formatting of WhitespaceSensitiveMacros
        </td>
    </tr>

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

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

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

<pre>
    Clang 14.0.0

When WhitespaceSensitiveMacros is enabled, multiline macros that are used as arguments get incorrectly aligned.

Sample code:

    #define SIGNAL(...) 0
    #define SLOT(...) 0
    
    void connect(...);
    
    class QObject;

    int main(QObject *something, QObject *other)
    {
       connect(something,   SIGNAL(currentSelectionChanged(QModelIndex,QModelIndex)),
           other, SLOT(onCurrentSelectionChanged(QModelIndex,QModelIndex)));
    }


Result without `WhitespaceSensitiveMacros` (inserts spaces inside the SIGNAL and SLOT macros which is undesirable because it negatively affects performance, see qt normalized signature):

    #define SIGNAL(...) 0
    #define SLOT(...) 0
    
    void connect(...);
    
    class QObject;
    
    int func(QObject *something, QObject *other) {
        connect(something, SIGNAL(currentSelectionChanged(QModelIndex, QModelIndex)),
                other, SLOT(onCurrentSelectionChanged(QModelIndex, QModelIndex)));
    }

Result with `WhitespaceSensitiveMacros` (everything that goes after the SIGNAL macro gets aligned as though it is inside of `SIGNAL()`)

    #define SIGNAL(...) 0
    #define SLOT(...) 0
    
    void connect(...);
    
    class QObject;
    
    int func(QObject *something, QObject *other) {
        connect(something,
                SIGNAL(currentSelectionChanged(QModelIndex,QModelIndex)), other,
                       SLOT(onCurrentSelectionChanged(QModelIndex,QModelIndex)));
    }

Expected result:

    #define SIGNAL(...) 0
    #define SLOT(...) 0
    
    void connect(...);
    
    class QObject;
    
    int func(QObject *something, QObject *other) {
        connect(something, SIGNAL(currentSelectionChanged(QModelIndex,QModelIndex)),
                other, SLOT(onCurrentSelectionChanged(QModelIndex,QModelIndex)));
    }

Configuration file:

    Language: Cpp
    IndentWidth: 4
    WhitespaceSensitiveMacros:
    - SIGNAL
    - SLOT



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztllFvmzAQxz8NvFhFxJA0eeAhTdetUrtqy6Q-G_sAT45htknbffqdSUnImkzt1k2aVBIR4zvufz5-OZzX4iFbKKZLMkqjOIqD-DyI55vzbQWa3FbSgW0YhyVoK51cwzXjprZEWgKa5QpEQBdk1SonldRAVhuzq5gjzABpLQjCLI7LdgXaWVKCI1Lz2hjgTj0QpmSpQURD8SVbNQoIrwUEyXxoIXgENBFQeLXl5fuP86uATqMoCuiMxAedrm6-HHbZjta1FKimNaa0dQ2Ss0O-XDFryaeb_Kt37n12dqkdVkFqjPPohLnMbb0CV0ld-nIN5mtXgfFiO6XTgazX26a1F4PsFs9brKV2S1DoJ2u9qPCR-gcz_XSNFVSXWsA93rN3Neu-iz0pfzwmtOjLhuF-P_xPNTw9HxZrc_4MFuEhd9JVdYslmcRHoUMblmwqtQWDIHUuSCL6CEDiehwI06LLvofxrpK88sS2mJuVxmNLcuAM4STSEQ0l8yoexqLARVrSgClqs2Kag6-FBSDf0NFPKfkdkbYILXOtgW6R_wWi-z4e06LV_GWYPqHzGJ4vhpM8i84_RPSQyC8ZHdD5HDRhDeahq8GmA5Y1AsoKB2bIZ4el74O2b36-Q3r-y8rzKLdQ14VX3dbSJzuJt93iDbf-3sOcvEqD3NJ2WKOX-tvN8t19gwGRFNMR-dZyXqHl_IuO89LnvKh1IcvWMB-UFFId2gBdoVbLSm8ii6bZGbyOdrdSuMrb0p3leOdKBoFP-iIOZ_ySn7y2Q5ElYpbMWOikU5Bxv4086d6ZHk7M5HGHRzZzzvdEbGdH8whbo7LKuabLiF7gt8Su2-YRr1d4odS6_zlpTN1hRi-ktS1YHIzHaZqEVSZiweloCjDOOZ0wLiY5HSX5OJ8IyuNZGiqWg7JZMD4LKNVwR7oQOA7G56HMaExpPB4loylNExpN2CRJJ3A6KjjeN0uDNAbc3KnI5xHVpgxN1qWUt6VFo5LW2Z0R_xO-v0Mnh_FZi13eZB9A4CfslLMu8x_v7mN-">