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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] overflow builtins always write their output operand
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

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

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

<pre>
    Consider the following code: 

```
int test(int elementSize, int elementCount)
{
        int bufferSize;
        int allocSize;
        bool overflow = __builtin_mul_overflow(elementCount, elementSize, &bufferSize);
        overflow |= __builtin_add_overflow(4, bufferSize, &allocSize);
        if (overflow)
                return -1;
        return allocSize;
}
```

clang-tidy-20 produces the following false-positive warning:

```
foo.cpp:6:14: warning: 2nd function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
    6 |         overflow |= __builtin_add_overflow(4, bufferSize, &allocSize);
```

This seems to be because it does not understand that the prior call to `__builtin_mul_overflow` will always write to `bufferSize`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVEGPszgM_TXhYrUKCVA4cGA66m1Pu_dRIAayShOUOK06v35Fp99X2tXetopU5OS9Zz9bVjGaySG2rPxg5WemEs0-tAGjieRD1nt9a4_eRaMxAM0Io7fWX42bYPAameyA8W49FX8c3hlHQBiJiXr9RItndPSn-UYmjrAJHX1yxESz4g8fd6Jmve7TOGK4A-QmrKz1w0u0996Cv2AYrb8Ck5_w9dUnY8m4r3OyX7-umKhfJY_vWTFRbVRF81viyX44vgoorbcCxUqz5biTPnPecJoRmKif2OYnzHgTkFJwsMt_v31E3ms_fL6Zzng3WOWmHRl92wkOS_A6DRjf2jYqG3G3-GjIXBCuKjjjJia7f_dx9H4_LAuTXcVklxdrt5_vQTgNY3IDGe9gUNaCClNaTQUTQTlIzjhDRlnzjRouyiYEVn78pKmcsrdvDLvBB9wflbWd039gjGpCVq7VAQBUq-3w6_f_9-LVwL9mEyEiniOQhx6hx0GliGAItMcIzhMkpzFEUk4DzYru9i7B-PDjAXlgFf-PMaw4XM1qlL2qW4RrMIQPxCbbiu8z3UrdyEZl2OaHopS15LLJ5rYopdaVqupDPoihRhRNU-KYNwddN1LyzLSCi5IXQvJCHvJm3xR5gXwclaykLBtkBcezMnZv7eW892HKTIwJ21xWdS4yq3q08b4QhHhOFBNiXRChXVG7Pk2RFdyaSPHJQ4bsfZVsYOXns2sPS-Jb-TOaAD7Rkgj8gkE5naVg25loietgihMTp8nQnPr94M9MnFbJx99uCf5vHIiJ072OyMTpUcqlFf8EAAD__xANkqo">