-
Notifications
You must be signed in to change notification settings - Fork 393
unnecessary <stdlib.h>
suggested for QList
#1655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
<stdint.h>
suggested for QList
<stdlib.h>
suggested for QList
I assume this might apply to other Qt containers. |
I cannot reproduce it with Qt 6.4.2. I get:
with your command line options and "has correct #includes/fwd-decls" when using An IWYU log might probably be helpful as well. |
I forgot to mention that. Will make sure my reports reflect that. This is with Qt 6.7+ without using the mapping files as the official includes now carry IWYU annotations. |
I still have |
I can reproduce it on Kali Linux using include-what-you-use 0.23-1+b1, gcc 14.2.0-12, clang 19.1.6-1+b1 and Qt 6.7.2. Here's the On my other distros I unfortunately have no up-to-date IWYU or Qt. |
Surprisingly, the difference was because I used the 12th version of libstdc++ and not the 14th. (A change in Qt introducing the call to IWYU has an heuristic to block reports of an internal stuff referenced inside templates from external libraries and resolved at instantiation time: Line 3440 in 30e221f
If some header in the template instantiation chain "provides" a declaration, then the declaration is not reported. "Provides" means "has anywhere in its #include tree" for "public" headers and "includes directly" for other headers:include-what-you-use/iwyu_preprocessor.cc Line 985 in 30e221f
The problem is that IWYU pragmas don't mark any header as public. Public headers are meant to exist in external libraries, for which there are mapping files. Therefore, as long as you don't use any Qt mapping file, the Qt headers are handled as if they are under your control. Hence, despite <QList> actually has #include <stdlib.h> buried inside its #include tree, IWYU doesn't "sees" it and decides that you are responsible for including it at the template instantiation place. Such a mapping file fixes the problem:
[
{ "include": ["\"qlist.h\"", "public", "<QList>", "public"] }
] Note that In comparison with IWYU 0.22, 0.23 indeed has a change leading to this report. I think it was mine (#1528). But why the problem didn't appear to me? I think the best way of fixing this would be to make a PR in Qt adding |
It turns out that such logic is already present in IWYU (see include-what-you-use/iwyu_path_util.cc Line 195 in f33e830
which doesn't seem to be correct but might be a trade-off, I'm not sure. Therefore, if you use |
That is an annoyance of This and the angle-quote confusion is something I also ran into with Cppcheck but I didn't have the time to look into this yet. But the original issue was encountered with a compilation database generated by CMake and the Qt includes are system ones in that case. |
I think that not so many people still use IWYU and even less open issues. Probably, someone will fix it on the IWYU side some day...
But you were not using a mapping file as you've said. |
I was not speaking about IWYU but about everything out there. If it is not a system header you should e.g. get flooded with compiler warnings you cannot fix.
Yes, because I want to move the annotations ahead so you do not need any at all. It is unfeasible to generate mappings for a library above a certain threshold. Unfortunately I am not even remotely focused on that right now. |
This started with 0.23.
The text was updated successfully, but these errors were encountered: