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

    <tr>
        <th>Summary</th>
        <td>
            [18.1.1][BUG][`clang-tidy`][`bugprone-inc-dec-in-conditions`] `decltype` should not count as a variable "reference"
        </td>
    </tr>

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

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

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

<pre>
    The new `bugprone-inc-dec-in-conditions` should not consider `decltype()` to be a reference of a variable when emitting this check.
```c++
int main()
{
    auto foo = 0;
    auto bar = 0;
    if (++foo < static_cast<decltype(foo)>(bar)) { }
    return 0;
}
```
```
[<source>:6:9: warning: incrementing and referencing a variable in a complex condition can cause unintended side-effects due to C++'s order of evaluation, consider moving the modification outside of the condition to avoid misunderstandings [bugprone-inc-dec-in-conditions]](javascript:;)
    6 |     if (++foo < static_cast<decltype(foo)>(bar)) { }
      |         ^
[<source>:6:38: note: variable is referenced here](javascript:;)
    6 |     if (++foo < static_cast<decltype(foo)>(bar)) { }
      | ^
1 warning generated.
```
https://godbolt.org/z/6ahz8qea7

Expected Behavior
-----------------
No diagnostics emitted for the above code, or, if this check intends to catch `++foo` itself, have the diagnostic reference the increment itself.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU2v6yYQ_TVkM0pkQ_y18CIfN5W66KpdV2MY27zakALOfff9-go7z0mjp95VpRcRGxhmxpxzGNB73RmimmVHlp03OIXeuvpXlLZpUTebxqqP-veewNA7sDxppu7qrKGtNnKrSG612UprlA7aGs_yBHxvp0GBsQGkNV4rctFRkRzCx5UYLxmv4sJgoSFAcNSSIyMJbAsIN3Qam4HgvScDNOoQtOkg9NqD7En-tWPJmSUHlidLk4wfY5tntQkwojb3NMvK4m4EAMApWGitBSbOkDDxamrQ_cCkW5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