Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.7.0
-
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
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
Issue Links
- relates to
-
QTBUG-45489 iwyu mapping file for Qt
- Closed
-
QTBUG-119505 Add IWYU pragma to forwarding headers?
- Closed