[PATCH] D99646: [clang-tidy] misc-std-stream-objects-outside-main: a new check

Marco Gartmann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 1 06:45:46 PDT 2021


mgartmann added a comment.

In D99646#2661651 <https://reviews.llvm.org/D99646#2661651>, @njames93 wrote:

> Is it not wise to also check the c standard library.
> So check for function refs to these names in the global or std namespace.
> `printf`, `vprintf`, `puts`, `putchar`, `scanf`, `scanf`, `getchar` and `gets`
> It may be a bit of a pain checking for usages of `stdin` and  `stdout` due to them being defined as macros.

Hi @njames93,
I can see your point, I am going to add this functionality.

However, I do not completely understand what you mean with //check for function refs to these names in the global or std namespace//.  
Could you explain this a bit further?

E.g., should all calls to these functions be flagged if they happen inside the `std` namespace or in the `global` namespace?
And if they happen inside `my_namespace` e.g., they should not be flagged. Am I understanding this correctly?
How should the check behave if the functions are called inside `main()`?

Would it make more sense to put this functionality into a separat check?

Thanks for your effort in advance.
Looking forward to hearing from you soon.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99646/new/

https://reviews.llvm.org/D99646



More information about the cfe-commits mailing list