<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - UNO API: headers including themselves, causes IWYU assertion"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=117918">117918</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>UNO API: headers including themselves, causes IWYU assertion
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.2.0.0.alpha0+ Master
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>framework
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>kelemeng@ubuntu.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>vmiklos@collabora.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="http://bugs.documentfoundation.org/attachment.cgi?id=142423" name="attach_142423" title="Diff between a fresh and a fixed up UnoApiHeadersTarget dir, showing problematic files">attachment 142423</a> <a href="http://bugs.documentfoundation.org/attachment.cgi?id=142423&action=edit" title="Diff between a fresh and a fixed up UnoApiHeadersTarget dir, showing problematic files">[details]</a></span>
Diff between a fresh and a fixed up UnoApiHeadersTarget dir, showing
problematic files

While trying to help on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - accelerating compile times by removing unnecessary header #include"
   href="show_bug.cgi?id=42949">bug #42949</a> I noticed that IWYU does not report
unnecessary headers for some larger files with a lot of includes.
A bit of investigation revealed that IWYU fails in such situations with an
assertion error, like this:

$ 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
-DSD_DLLIMPLEMENTATION -DSDUI_DLL_NAME=\"libsduilo.so\" -DENABLE_SDREMOTE
-DENABLE_SDREMOTE_BLUETOOTH -DLIBO_INTERNAL_ONLY
-I/home/gabor/src/core/workdir/UnpackedTarball/icu/source
-I/home/gabor/src/core/workdir/UnpackedTarball/icu/source/i18n
-I/home/gabor/src/core/workdir/UnpackedTarball/icu/source/common
-I/home/gabor/src/core/external/boost/include
-I/home/gabor/src/core/workdir/UnpackedTarball/boost
-I/home/gabor/src/core/external/bluez_bluetooth/inc
-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/sd/inc
-I/home/gabor/src/core/sd/source/ui/inc
-I/home/gabor/src/core/sd/source/ui/slidesorter/inc
-I/home/gabor/src/core/workdir/SdiTarget/sd/sdi
-I/home/gabor/src/core/workdir/CustomTarget/officecfg/registry
-I/home/gabor/src/core/workdir/UnoApiHeadersTarget/udkapi/normal
-I/home/gabor/src/core/workdir/UnoApiHeadersTarget/offapi/normal
-I/home/gabor/src/core/workdir/UnpackedTarball/libxml2/include -isystem
/usr/include/dbus-1.0 -isystem /usr/lib/x86_64-linux-gnu/dbus-1.0/include
-isystem /usr/include/glib-2.0 -isystem
/usr/lib/x86_64-linux-gnu/glib-2.0/include -finput-charset=UTF-8
-fmessage-length=0 -fno-common -pipe -fvisibility-inlines-hidden -fPIC
-std=c++11 -c -x c++ /home/gabor/src/core/sd/inc/AnnotationEnumeration.hxx
Cycle in include-mapping:
  "com/sun/star/text/XTextRange.hpp" ->
  "com/sun/star/text/XTextRange.hpp"
/build/iwyu-mhPUyW/iwyu-5.0/iwyu_include_picker.cc:845: Assertion failed: Cycle
in include-mapping

Looking at
workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/text/XTextRange.hpp the
problem is clear: it contains an include of itself:

#include "com/sun/star/text/XTextRange.hpp"

Commenting this line out causes the assertion error to disappear. That is,
until it hits a similar problem - so far, to get IWYU to run on sd/inc and
chart2/inc needed commenting out 17 self includes.

I think it would be helpful to fix the underlying problem on the LO side and
stop generating hpp files with includes to themselves. 
That way IWYU and the find-unneeded-includes script could give relevant results
about all the headers.

I'm using:
include-what-you-use 0.9 based on clang version 5.0.1-2
(tags/RELEASE_501/final)
on Ubuntu 18.04.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>