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

    <tr>
        <th>Summary</th>
        <td>
            Extend `bugprone-unchecked-optional-access` to All Types
        </td>
    </tr>

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

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

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

<pre>
    Currently, the `bugprone-unchecked-optional-access` check only applies to optional-like types. However, why don't we extend this check to all types? This would allow user-defined types to be verified with specific methods before they are used.

For example, consider pointer usage. When using pointers, we should first check if the pointer is not null. In my view, these two cases (optional and pointer) are similar because both require validation before use to prevent potential runtime errors.

Extending bugprone-unchecked-optional-access to all types could provide the following benefits:
1. Enhanced Safety: Automatically checking user-defined types before use can prevent common runtime errors, increasing the overall safety of the code.
2. Consistency: Having a uniform check for all types ensures that the same standards are applied throughout the codebase, improving maintainability.
3. Early Error Detection: By ensuring all types are checked, potential issues can be caught early in the development process, reducing debugging time.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE2P2zYT_jXyZWDDS3-tDjpsdtfIe05e5DwiR9I0FKmSQzn69wUpe5MUBdqLDZiceT5NjJF7R9RUp0_V6W2DSQYfmm9f_n9Ft2m9WZrXFAI5sUulXkEGguq8b1M_Be9om5weSH8ns_WTsHdot6g1xVid91COwDu7AE6TZYogHj4uWv5OIMtEcQef_Y1mChniNixgvKvUReBGQD-EnAEZON4Xige0dp2sDlf4mo9uPlmTf_c3SJHC1lDHjsx6Lc-0BDMF7pgM3FgGiBNp7ljDSDJ4E6GlzgfKGhfAQHmP2VX7t2r_sn5efQD6geNkKTPV3kU2FGDy7IQCpIg97eDbQA5SZNc_TmIRRhCHQrPjEOWuhrti6mMFR3BewCVrd_A_B-MCM9Pt7n0kkJsHjZEiVOr54SWgM48VlaoL-8gjWwzQks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