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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Warning-request: calling a function that converts a pointer argument to bool parameter should issue a warning
        </td>
    </tr>

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

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

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

<pre>
    In an overload set that involves `bool`, it's too easy to fall into the trap where the users are meant to pass the pointer or string literal argument to a more appropriate candidate but end up passing it to the candidate that takes `bool`. A typical case involves
```cpp
void bar(bool);
void bar(std::string);
```
Clang introduced [-Wstring-conversion](https://clang.llvm.org/docs/DiagnosticsReference.html#id877) to diagnose the case where the argument is a string literal,
```cpp
bar("");
```
but not overwise.
```cpp
bar(sz);
```
The non-literal case should also be diagnosed.
The diagnosis should also not be limited to boolean conversion from pointer to strings. Any pointers can fall into this trap:
```cpp
void foo(bool);
void foo(void *);

void test1(T *sp)
{
    foo(sp); // should give a warning
}
```

If we have concerns about the situation where calling a function that takes `bool` with a pointer can appear frequently in practice, we could limit the scope to overload resolution. In other words, if overload resolution calls a candidate that converts a pointer argument to a bool parameter, Clang issues a warning, but this will be more involved.

Repro: https://godbolt.org/z/WbsMnYnW9
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVU1v8jgQ_jXmMgIFh_Bx4ECLkHrYy6tXqvY4cQbiXWNnPRMQ_fUrOxRKt-1KCEg8nszz4SfIbA-eaK2qJ1VtR9hLG-L6rbUthsuoDs1l_eIBPYQTRRewASYBaVHA-lNwJ2JQ86IOwal5ofQzWFF6wSAhACFfQALs0TmwXgJISyAROzi3FClf9kyRASPBkdBLqu-QOa91wXqhCCECS7T-AM4KRXSA8dAfaShHOIZIgF0XQxctCoFB39gm_at7AfIN9F1um3rYvCv1v5dlRIJ_P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