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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] create a check to ensure std:: qualified names used with C++ C standard headers
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy,
            check-request
      </td>
    </tr>

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

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

<pre>
    If you include `<cctype>` and don't import the namespace `std`, you should be using function names qualified by namespace `std`.

While it is a common implementation detail for the C++ style header to include the C header and do something like import the names from the global namespace into namespace `std`, the standard itself doesn't require that the C names be available in the global namespace.

This, after all, is the whole point of the C++ style headers like `<cctype>` -- to put the identifiers in namespace `std` and not pollute the global namespace.

However, because of the common implementation mechanism described above, it is too easy to drop the namespace qualifier and have the code "working by accident" instead of "working by design".

For such a check, there is the additional complication that the C style headers may have been included transitively and therefore the C style identifiers are indeed guaranteed to be in the global namespace.

Example:

```
#include <cctype>

bool is_upper_case(char c)
{
    return isupper(static_cast<unsigned char>(c)) != 0;  // warning issued here
    // fixit: insert `std::` before `isupper`
}
```

Example:
```
#include <cctype>

using namespace std;

bool is_upper_case(char c)
{
    return isupper(static_cast<unsigned char>(c)) != 0;  // no warning issued here
}
```

To implement this check, I think you'll need to enumerate all the symbols in namespace `std` that are provided by a C++ version of a C standard header.  Maybe there's a better way, but I can't think of it off the top of my head.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVk1v2zgT_jX0ZRBDpmzLPvjgJA3eAu_eCuyxGJEjixuKVPnhVPvrF0PZSdo6xd4WEJBIIIfPF2eMMZqTIzqIzb3YPC4wp96Hw__phNb8TUedbeq914vW6-nwuYPJZzBO2awJxLYS9YNSaRpJ1J_EtgJ0GrR3QjYJzDD6kCD1BA4HiiOqsicmzTvlQykWe5-thpYgR-NO0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