While working on https://gerrit.libreoffice.org/#/c/59956/ I noticed that IWYU gives wrong results and errors about files not found: $ include-what-you-use -Wall -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_SYSTEM_NO_DEPRECATED -DCPPU_ENV=gcc3 -DLINUX -DOSL_DEBUG_LEVEL=1 -DSAL_LOG_INFO -DSAL_LOG_WARN -DUNIX -DUNX -DX86_64 -D_PTHREADS -D_REENTRANT -DLIBO_INTERNAL_ONLY -I/home/gabor/src/core/external/boost/include -I/home/gabor/src/core/workdir/UnpackedTarball/boost -I/home/gabor/src/core/include -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/gabor/src/core/config_host -I/home/gabor/src/core/chart2/source/controller/inc -I/home/gabor/src/core/chart2/source/inc -I/home/gabor/src/core/chart2/inc -I/home/gabor/src/core/workdir/UnoApiHeadersTarget/udkapi/normal -I/home/gabor/src/core/workdir/UnoApiHeadersTarget/offapi/normal -finput-charset=UTF-8 -fmessage-length=0 -fno-common -pipe -fvisibility-inlines-hidden -fPIC -std=gnu++1y -c -x c++ /home/gabor/src/core/chart2/source/view/axes/Tickmarks.hxx In file included from /home/gabor/src/core/chart2/source/view/axes/Tickmarks.hxx:22: /home/gabor/src/core/chart2/source/view/axes/TickmarkProperties.hxx:23:10: fatal error: 'VLineProperties.hxx' file not found #include <VLineProperties.hxx> ^~~~~~~~~~~~~~~~~~~~~ $ include-what-you-use -Wall -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_SYSTEM_NO_DEPRECATED -DCPPU_ENV=gcc3 -DLINUX -DOSL_DEBUG_LEVEL=1 -DSAL_LOG_INFO -DSAL_LOG_WARN -DUNIX -DUNX -DX86_64 -D_PTHREADS -D_REENTRANT -DLIBO_INTERNAL_ONLY -I/home/gabor/src/core/external/boost/include -I/home/gabor/src/core/workdir/UnpackedTarball/boost -I/home/gabor/src/core/include -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/gabor/src/core/config_host -I/home/gabor/src/core/chart2/source/controller/inc -I/home/gabor/src/core/chart2/source/inc -I/home/gabor/src/core/chart2/inc -I/home/gabor/src/core/workdir/UnoApiHeadersTarget/udkapi/normal -I/home/gabor/src/core/workdir/UnoApiHeadersTarget/offapi/normal -finput-charset=UTF-8 -fmessage-length=0 -fno-common -pipe -fvisibility-inlines-hidden -fPIC -std=gnu++1y -c -x c++ /home/gabor/src/core/chart2/source/view/charttypes/BarChart.hxx /home/gabor/src/core/chart2/source/view/charttypes/BarChart.hxx:24:10: fatal error: 'VSeriesPlotter.hxx' file not found #include <VSeriesPlotter.hxx> ^~~~~~~~~~~~~~~~~~~~ The problem affects only these two directories, and not chart2/source/view/main. Here the problem is this include directory specification: -I/home/gabor/src/core/chart2/source/controller/inc The correct one would be: -I/home/gabor/src/core/chart2/source/view/inc Since this contains the "not found" files. Manually editing the above command lines makes IWYU find all files and work as usual.
Usually we use bugzilla only for user-visible bugs. :-) Anyway, chart2/source/view/charttypes/BarChart.cxx is in Library_chartcore, but chart2/Library_chartcore.mk (its gb_Library_set_include) section already includes the correct include directories. The root of your problem is that gbuild in general has no idea about what flags to use to "compile" headers; the assumed filename is set in chart2/IwyuFilter_chart2.yaml, but that one is only able to handle headers which are available for all char2 translation units, i.e. chart2/inc/* and chart2/source/inc/*. So the bug is confirmed, but I would consider it a low priority: I wish our largest problem at the moment would be those "internal" headers, given that all of include/* and foo/inc/* would be already IWYU-clean. ;-)
Gabor Kelemen committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/64d8a71eb8ced0b701ba86e5cf066af48f98872f tdf#42949 tdf#119699 Fix IWYU warnings in chart2/ It will be available in 6.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.