Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-124159

IWYU incorrect header suggestions

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.7.0
    • Build System
    • None
    • Linux 18185233fd1e 6.6.16-linuxkit #1 SMP Fri Feb 16 11:54:02 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
    • Linux/X11

    Description

      Header support for IWYU (include-what-you-use) was added with https://bugreports.qt.io/browse/QTBUG-119505

      It has a number of issues compared to using 6.6.3 with the iwyu-mapgen-qt.py tool https://raw.githubusercontent.com/include-what-you-use/include-what-you-use/clang_13/mapgen/iwyu-mapgen-qt.py

      • Code using QStringList that includes <QStringList> is recommended to remove that and use <qcontainerfwd.h>
      • <qlist.h> is recommended for QList instead of <QList>
      • <qtclasshelpermacros.h> is recommended for Q_DISABLE_COPY instead of <QObject>
      • <qtmetamacros.h> is recommended for Q_OBJECT instead of <QObject>
      • <QtCore/qobjectdefs.h> is recommended when using QObject::connect() with function pointers
      • <qguiapplication.h> is recommended when qApp is used, even though <QCoreApplication> is included
      • <qnamespace.h> is recommended for Qt::QueuedConnection instead of <Qt>

      Using the IWYU iwyu-mapgen-qt.py tool to generate a mapping file with 6.6.3 fixes the above.

      See the attached sample app, iwyu-sample.zip.

      For 6.7.0 it was configured as follows:

      $ mkdir build
      $ CC="clang" CXX="clang++" cmake -S . -B build -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="/usr/bin/iwyu;-Xiwyu;--cxx17ns" --install-prefix /usr/local/Qt/6.7.0/gcc_64/
      $ cmake --build build
      

      IWYU output is attached as iwyu-6.7.0.log

       For 6.6.3 with iwyu-mapgen-qt.py, it was configured as follows:

      $ curl -o "build/iwyu-mapgen-qt.py" https://raw.githubusercontent.com/include-what-you-use/include-what-you-use/clang_13/mapgen/iwyu-mapgen-qt.py
      $ python3 "build/iwyu-mapgen-qt.py" /usr/local/Qt/6.6.3/gcc_64/include > "build/qt6.6.3.imp"
      $ CC="clang" CXX="clang++" cmake -S . -B build -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="/usr/bin/iwyu;-Xiwyu;--cxx17ns;-Xiwyu;--mapping_file=$PWD/build/qt6.6.3.imp" --install-prefix /usr/local/Qt/6.6.3/gcc_64/
      $ cmake --build build
      

      IWYU output is attached as iwyu-6.6.3.log

      Attachments

        1. iwyu-6.6.3.log
          0.8 kB
        2. iwyu-6.7.0.log
          2 kB
        3. iwyu-sample.zip
          2 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtbuildsystem Qt Build System Team
              rectalogic Andrew Wason
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes