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

    <tr>
        <th>Summary</th>
        <td>
            cppcoreguidelines-prefer-member-initializer fails to initialize values with macros
        </td>
    </tr>

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

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

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

<pre>
    clang-tidy check cppcoreguidelines-prefer-member-initializer (as shipped with LLVM 17.0.1) removes the values when the value would be expanded from a preprocessor macro. Instead, the member is default initialized, which leads to different behavior.

Before:
```
#define RGB(r,g,b) ((unsigned long)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((unsigned long)(unsigned char)(b))<<16)))
#define INVALID_HANDLE_VALUE ((void*)(unsigned long long)-1)
#define SIMPLE 12

class Foo
{
public:
    Foo()
    {
        m_color = RGB(255, 128, 0);
        m_handle = INVALID_HANDLE_VALUE;
 m_myval = SIMPLE;
    }
private:
    unsigned long m_color;
 void* m_handle;
    int m_myval;
};
```
After applying cppcoreguidelines-prefer-member-initializer the function like macro RGB and also INVALID_HANDLE_VALUE are completely removed leading to wrong results. However the SIMPLE is kept.

After:
```
#define RGB(r,g,b) ((unsigned long)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((unsigned long)(unsigned char)(b))<<16)))
#define INVALID_HANDLE_VALUE ((void*)(unsigned long long)-1)
#define SIMPLE 12

class Foo
{
public:
    Foo() : m_color(), m_handle(), m_myval(SIMPLE)
    {
        
        
        
 }
private:
    unsigned long m_color;
    void* m_handle;
    int m_myval;
};
```

Expected result:
```
#define RGB(r,g,b) ((unsigned long)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((unsigned long)(unsigned char)(b))<<16)))
#define INVALID_HANDLE_VALUE ((void*)(unsigned long long)-1)
#define SIMPLE 12

class Foo
{
public:
    Foo() : m_color(RGB(255, 128, 0)), m_handle(INVALID_HANDLE_VALUE), m_myval(SIMPLE)
    {
        
 
        
    }
private:
    unsigned long m_color;
 void* m_handle;
    int m_myval;
};
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVttu2zgQ_Rr6ZWBBonyRHvTg2PEmgFss9pLXgCJHEjcUKZCUXe_XL3SJHKfuYosuUBSoYUiaIWfmDHkOSOacLDViRpZ3ZLmbsdZXxmZ_VKZm7qFF73g1y404Z1wxXc69FGfgFfIX4E3DjcWylQKV1OjmjcUC7bzGOkc7l1p6yZT8Gy0QmjAHrpJNgwJO0ldwODx9gGgdhEFEaAoWa3NEB75CODLVooNThfpiw8m0SkCOgJ8apgUKKKypgUFjsbGGo3PGQs24NQE8aueRCUK3fYYBEkgHAgvWKg8XdP2kUyV5BQqZcOANCFkUaFF7yLFiR2lsQMIdCTfD8w4LY5HEo0lW4fgfTBoLLKRG-O2XO0ITS-i2JHSbd30SmhCatLpfdgHK6JLQdPC-HeAVs8NA_1pv3427ylg_Rd4IG9KmJN6SeJuMxmua2xBuZMnfZolWo0XT950-fnzaHB53zw-bj7vD_fPT5vDn_djr0UhB6OZdia7qa-l5dCPj748ffj3cQ0TfLjxXzDnYGzM613fDR9PmSvJpQwCgn0STKXHnmqbD-KufuVHGAol3417R5bKjQ9RFbiHsW_8sqGJaKOyjbvV9iaif6_ORqX7m0M9VNrLejfCtPDKPV_ivV2pEegkfV3VCc5VYav9ae_J3xabva8JuCo8WWNOos9TlVwm7E1fRau6l0aDkCw4C7FYTmBbAlDO3ycEsAjd1o9CjOo_6F70EOxDewMl2nVt0rfIugAdzwuNYciSHdPCCjb_SZt_MT2n-ENIEEm8mag9ipdsLpd94Bi7TZFTRv6r6P1jfojyA_1V8w_P-U4Pcoxjp_pO_PyJ_v3iEfMbrm8fGN3D9S5T__ifMTGSxSOOUzTCLVmlCaRpFq1mVJRgjsiKhyxXmgierpFgUnMY5FoskRJzJjIY0jkK6jMIoiVcB5kVKWboWC5YkKeNkEWLNpAqUOtaBseVMOtditg6jJJ0plqNy_b2WUo0n6AcJpd0112ZdzDxvS0cWoZLOu0sWL73C7GtOwYJJ1d8bL87pEtvddfsz0c1aq7LK-8Z120D3hO5L6as2D7ipCd13AMbXvLHmL-Se0H0P2xG679v6JwAA__-DlFu3">