SUMMARY When connecting to QAbstractItemView::entered signal, clazy doesn't recognize it as a signal. STEPS TO REPRODUCE 1. Subclass a QTreeWidget 2. In the constructor, include something like this: connect(this, &QTreeWidget::entered, this, []{}); //or// connect(this, &QAbstractItemView::entered, this, []{}); 3. Run clazy OBSERVED RESULT Clazy warns that the ::entered signal as not a signal EXPECTED RESULT Clazy recognizes the ::entered signal as a signal and no warning is given SOFTWARE/OS VERSIONS Windows: 10 macOS: Linux/KDE Plasma: (available in About System) KDE Plasma Version: KDE Frameworks Version: Qt Version: 5.12.1 ADDITIONAL INFORMATION
Git commit d3f6b6606b170c7daf8abdd24ac69e562e86b9b8 by Sergio Martins. Committed on 10/01/2021 at 13:40. Pushed by smartins into branch 'master'. connect-non-signal: Add a testcsae for bug 431186 I can't reproduce A +9 -0 tests/connect-non-signal/bug431186.cpp * A +0 -0 tests/connect-non-signal/bug431186.cpp.expected M +3 -0 tests/connect-non-signal/config.json The files marked with a * at the end have a non valid license. Please read: https://community.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page. https://invent.kde.org/sdk/clazy/commit/d3f6b6606b170c7daf8abdd24ac69e562e86b9b8
Do you have either precompiled headers turned on, or ccache running ? Can you paste the complete compiler invocation ?
Created attachment 134713 [details] pro file
Created attachment 134714 [details] main file
Created attachment 134715 [details] mainwindow file
Created attachment 134716 [details] mainwindow header
Created attachment 134717 [details] subclass implementation; bug found here
Created attachment 134718 [details] subclass header
Using Qt 5.12.1, with both MinGW 64 bit and a MinGW Static compile
Apologies if this is not the info you need. Not consciously using precompiled headers or ccache. 11:29:47: Running steps for project clazybugtest... 11:29:47: Starting: "C:\Qt\5.12.1\mingw73_64\bin\qmake.exe" "C:\Users\...\Files\CPP\Qt\clazybugtest\clazybugtest.pro" -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" Info: creating stash file C:\Users\...\Files\CPP\Qt\build-clazybugtest-Desktop_Qt_5_12_1_MinGW_64_bit-Debug\.qmake.stash 11:29:48: The process "C:\Qt\5.12.1\mingw73_64\bin\qmake.exe" exited normally. 11:29:48: Starting: "C:\Qt\Tools\mingw730_64\bin\mingw32-make.exe" -f "C:/Users/.../Files/CPP/Qt/build-clazybugtest-Desktop_Qt_5_12_1_MinGW_64_bit-Debug/Makefile" qmake_all mingw32-make: Nothing to be done for 'qmake_all'. 11:29:49: The process "C:\Qt\Tools\mingw730_64\bin\mingw32-make.exe" exited normally. 11:29:49: Starting: "C:\Qt\Tools\mingw730_64\bin\mingw32-make.exe" -j4
thanks can you upload a single .zip and make sure it compiles ? I think something went wrong with your upload, some files say: #include "Error in " Util.relativeFilePath('C:/Users/jhertz/Dropbox (NU College of Eng'g)/Files/CPP/Qt/mainwindow.h', 'C:/Users/jhertz/Dropbox (NU College of Eng'g)/Files/CPP/Qt' + '/' + Util.path('mainwindow.cpp'))": SyntaxError: Unexpected token `identifier'" #include "ui_mainwindow.h"
Created attachment 134723 [details] Clazy bug project Hopefully this is sufficient. Apologies if not.
thanks, that built fine, but doesn't show the problem Is this something you're seeing when compiling the project with clazy = (clang+mingw+clazy plugin) or is this a warning you're seeing in QtCreator code analysis tools (which underlines the problem) ?
Qtcreator code analysis tools, both the "realtime" analysis that underlines the text and the "Analyze > Clang-Tidy and Clazy" anlysis.
Hmmm...I get the same "...is not a signal [clazy-connect-non-signal]" warning when connecting to all of these signals that are inherited from QAbstractItemView connect(this, &QTreeWidget::entered, this, &treewidg::itemEntered); connect(this, &QTreeWidget::pressed, this, &treewidg::itemEntered); connect(this, &QTreeWidget::viewportEntered, this, &treewidg::itemEntered); connect(this, &QTreeWidget::activated, this, &treewidg::itemEntered); connect(this, &QTreeWidget::clicked, this, &treewidg::itemEntered); as well as from these signals inherited from QTreeView: connect(this, &QTreeWidget::collapsed, this, &treewidg::itemEntered); connect(this, &QTreeWidget::expanded, this, &treewidg::itemEntered); but NOT from any of these signals inherited from QTreeWidget: connect(this, &QTreeWidget::itemEntered, this, &treewidg::itemEntered); connect(this, &QTreeWidget::itemExpanded, this, &treewidg::itemEntered); connect(this, &QTreeWidget::itemPressed, this, &treewidg::itemEntered); connect(this, &QTreeWidget::currentItemChanged, this, &treewidg::itemEntered); connect(this, &QTreeWidget::itemSelectionChanged, this, &treewidg::itemEntered);
This is a bug in QtCreator's clazy integration, needs to be reported at https://bugs.qt.io instead
Reported to QtCreator bugs, but: This is reproducible outside Qt Creator. E.g. for the project in test.zip, pass -DCMAKE_EXPORT_COMPILE_COMMANDS to the cmake command line, and then run clazy-standalone with -p <build dir> on your file. You will get the same false positive as in Creator (on macOS at least; this particular example does not trigger for me on Linux, but I've seen the warning in more complex projects).
Interesting, can you open the compile_commands.json, go to the line of your translation unit, and start removing compiler flags until you can't repro ? I think there's some flag which is the culprit. Another idea is to test clazy from https://downloads.kdab.com/clazy/1.8/clazy_v1.8-msvc2019.zip instead of the one shipped with QtC.
I tried with 1.8 on my MacOS (built it myself) and it worked (as it did with Qt creator 4.13 before). No warnings.
interestingly, I tried clay 1.9 that I built myself and it is also fine...
hmm I tried again and now I'm getting those warnings. There must be something in the environment somewhere that is making a difference.
What do we know so far, is it Windows only ? Thierry, did you repro on macOS ? Anyone repro on Linux ?
Thierry, can you reproduce with clazy master ?
I can reproduce the issue on macOS (11.2). I managed to track this down to Reapply d6b07989e7a9211b21ecb9b9f8bd4d237bcc453e. (2575f65c) https://invent.kde.org/sdk/clazy/-/commit/2575f65c021a8ae18aa2de2bab4b07c8fc2b4a6b
can you paste here the commands you use to compile and install clazy ? If it's done within a QtCreator build, are there instructions I can do the same ?
(In reply to Sergio Martins from comment #25) > can you paste here the commands you use to compile and install clazy ? > If it's done within a QtCreator build, are there instructions I can do the > same ? Sure. mkdir build && cd build && cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_PREFIX_PATH=/usr/local/opt/llvm .. && cmake --build . && cmake --install . LLVM in /usr/local/opt/llvm is from brew, version 11.1.0. cmake version 3.19.4 ninja version 1.10.2 Xcode 12.4 I point Qt Creator to that clazy-standalone binary in the options (Analyzer > Clang Tools).
thanks, I'll have a try
I've finally reproduced without QtCreator. Needs the -export-fixes=foo argument to reproduce
Git commit 876796fb007cd6245fda37b6035b2504fdb6ad6e by Sergio Martins. Committed on 25/02/2021 at 20:16. Pushed by smartins into branch '1.9'. Fix -Wconnect-non-signal when fixits are enabled on macOS Partially reverts d6b07989e7a921. The fixit for copyable-polymorphic is now guarded by an opt-in env variable. I think it's not worth the slow down anyway, and since it causes regressions for connect-non-signal, disable it by default M +9 -2 src/AccessSpecifierManager.cpp M +1 -0 src/AccessSpecifierManager.h https://invent.kde.org/sdk/clazy/commit/876796fb007cd6245fda37b6035b2504fdb6ad6e
Just for the record: clazy-incorrect-emit was also affected (and is now fixed).