Re: Issue 1035 in include-what-you-use: Transitive includes not analyzed?

4 views
Skip to first unread message

notifi...@include-what-you-use.org

unread,
Nov 25, 2022, 5:25:37 PM11/25/22
to include-wh...@googlegroups.com
Comment #10 on issue 1035 by firewave: Transitive includes not analyzed?
https://github.com/include-what-you-use/include-what-you-use/issues/1035

@danielh2942 I did not see any mention of that in the release notes so I am curious.

I have CMake 3.25 available now and prepared a PR to get this working in the CI: https://github.com/danmar/cppcheck/pull/4599

It appears to work better but still appears to have some shortcomings. `valueflow.cpp` and `token.h` give a strange second entry which basically suggests to remove all includes and forward declarations.

It also seems like it will require include to be specified as `PUBLIC` as the `PRIVATE` ones appear to be ignored. Or maybe the `target_sources()` need to be defined at a later point. Have not looked into that.


notifi...@include-what-you-use.org

unread,
Nov 25, 2022, 5:32:51 PM11/25/22
to include-wh...@googlegroups.com
Comment #11 on issue 1035 by danielh2942: Transitive includes not analyzed?
https://github.com/include-what-you-use/include-what-you-use/issues/1035

@firewave I wrote the change that made it more IWYU friendly, All it does is tack ```//IWYU pragma: associated``` on to the end of the include in the ```.h.cxx``` files generated by the ```VERIFY_INTERFACE_HEADER_SETS``` target so it probably does require some more config wrangling.


notifi...@include-what-you-use.org

unread,
Nov 27, 2022, 2:28:08 PM11/27/22
to include-wh...@googlegroups.com
Comment #12 on issue 1035 by firewave: Transitive includes not analyzed?
https://github.com/include-what-you-use/include-what-you-use/issues/1035

Going through the issues in detail (more comments to follow):

```
(/__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cmdlineparser.h.cxx has correct #includes/fwd-decls)

In file included from /__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx:1:
/__w/cppcheck/cppcheck/cli/cppcheckexecutor.h:22:10: fatal error: 'color.h' file not found
#include "color.h"
```

```json
{
"directory": "/__w/cppcheck/cppcheck/cmake.output/cli",
"command": "/usr/bin/c++ -DCHECK_INTERNAL -DFILESDIR=\\\"/usr/local/share/Cppcheck\\\" -DHAVE_RULES -DTIXML_USE_STL -I/__w/cppcheck/cppcheck/cmake.output/cli -I/__w/cppcheck/cppcheck/cli -x c++ -O3 -DNDEBUG -O2 -pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -pipe -Woverloaded-virtual -Wno-maybe-uninitialized -Wsuggest-attribute=noreturn -Wno-shadow -std=gnu++11 -o CMakeFiles/cli_objs_verify_interface_header_sets.dir/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx.o -c /__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx",
"file": "/__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx"
}
```

```
add_library(cli_objs OBJECT ${hdrs} ${srcs})
[...]
if (CMAKE_VERIFY_INTERFACE_HEADER_SETS)
target_sources(cli_objs PUBLIC FILE_SET HEADERS TYPE HEADERS FILES ${hdrs})
endif()
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
```

This can be "fixed" by changing `target_include_directories()` to `PUBLIC`:

```json
{
"directory": "/__w/cppcheck/cppcheck/cmake.output/cli",
"command": "/usr/bin/c++ -DCHECK_INTERNAL -DFILESDIR=\\\"/usr/local/share/Cppcheck\\\" -DHAVE_RULES -DTIXML_USE_STL -I/__w/cppcheck/cppcheck/cmake.output/cli -I/__w/cppcheck/cppcheck/cli -I/__w/cppcheck/cppcheck/lib -x c++ -O3 -DNDEBUG -O2 -pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -pipe -Woverloaded-virtual -Wno-maybe-uninitialized -Wsuggest-attribute=noreturn -Wno-shadow -std=gnu++11 -o CMakeFiles/cli_objs_verify_interface_header_sets.dir/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx.o -c /__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx",
"file": "/__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx"
}
```


notifi...@include-what-you-use.org

unread,
Nov 27, 2022, 2:33:53 PM11/27/22
to include-wh...@googlegroups.com
Comment #13 on issue 1035 by firewave: Transitive includes not analyzed?
https://github.com/include-what-you-use/include-what-you-use/issues/1035

No `*.h.cxx` entries are generated for executable targets:

```
add_executable(testrunner ${testrunner_SOURCES})
if (CMAKE_VERIFY_INTERFACE_HEADER_SETS)
target_sources(testrunner PUBLIC FILE_SET HEADERS TYPE HEADERS FILES ${hdrs})
endif()
```


notifi...@include-what-you-use.org

unread,
Nov 27, 2022, 2:45:27 PM11/27/22
to include-wh...@googlegroups.com
Comment #13 on issue 1035 by firewave: Transitive includes not analyzed?
https://github.com/include-what-you-use/include-what-you-use/issues/1035

Going through the issues in detail (more comments to follow):

```
(/__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cmdlineparser.h.cxx has correct #includes/fwd-decls)

In file included from /__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx:1:
/__w/cppcheck/cppcheck/cli/cppcheckexecutor.h:22:10: fatal error: 'color.h' file not found
#include "color.h"
```

```json
{
"directory": "/__w/cppcheck/cppcheck/cmake.output/cli",
"command": "/usr/bin/c++ -DCHECK_INTERNAL -DFILESDIR=\\\"/usr/local/share/Cppcheck\\\" -DHAVE_RULES -DTIXML_USE_STL -I/__w/cppcheck/cppcheck/cmake.output/cli -I/__w/cppcheck/cppcheck/cli -x c++ -O3 -DNDEBUG -O2 -pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -pipe -Woverloaded-virtual -Wno-maybe-uninitialized -Wsuggest-attribute=noreturn -Wno-shadow -std=gnu++11 -o CMakeFiles/cli_objs_verify_interface_header_sets.dir/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx.o -c /__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx",
"file": "/__w/cppcheck/cppcheck/cmake.output/cli/cli_objs_verify_interface_header_sets/cppcheckexecutor.h.cxx"
}
```

```cmake
add_library(cli_objs OBJECT ${hdrs} ${srcs})
[...]
if (CMAKE_VERIFY_INTERFACE_HEADER_SETS)
target_sources(cli_objs PUBLIC FILE_SET HEADERS TYPE HEADERS FILES ${hdrs})
endif()

notifi...@include-what-you-use.org

unread,
Nov 27, 2022, 2:45:31 PM11/27/22
to include-wh...@googlegroups.com
Comment #13 on issue 1035 by firewave: Transitive includes not analyzed?
https://github.com/include-what-you-use/include-what-you-use/issues/1035

No `*.h.cxx` entries are generated for executable targets:

```cmake
add_executable(testrunner ${testrunner_SOURCES})
if (CMAKE_VERIFY_INTERFACE_HEADER_SETS)
target_sources(testrunner PUBLIC FILE_SET HEADERS TYPE HEADERS FILES ${hdrs})
endif()
```


Reply all
Reply to author
Forward
0 new messages