SUMMARY If compile_commands.json contains '-std=c++17' or if I use -extra-arg='-std=c++17' then warning about usage of 3 argument connect disappear STEPS TO REPRODUCE Build clazy from source code (90fc09d3047792e585d07a78a79f9648f7d5fb1c) and run ./build/bin/clazy-standalone -extra-arg='-std=c++17' -extra-arg='-I/usr/include/qt' -extra-arg='-I/usr/lib/clang/11.1.0/include' tests/connect-3arg-lambda/main.cpp OBSERVED RESULT No warnings about 'Pass a context object as 3rd connect parameter' EXPECTED RESULT Warnings with text 'Pass a context object as 3rd connect parameter' SOFTWARE/OS VERSIONS Arch Linux, Qt Version: 5.15.2+kde+r192 ADDITIONAL INFORMATION I tried clazy/tests/run_tests.py . By default all tests passed, but if I replace -std=c++14 with -std=c++17, then such tests failed: connect-3arg-lambda reserve-candidates qt6-qlatin1stringchar-to-u range-loop-detach qstring-allocations container-anti-pattern detaching-member qstring-allocations
Looks like this is expected behavior of clang/libclang: for code like this: #define signals public class QObject { signals: void destroyed(); public: template<typename F> static void connect(QObject *, void (QObject::*mf)(void), F f) {} void deleteLater(); }; void test(QObject *o1, QObject *o2) { QObject::connect(o1, &QObject::destroyed, [=] { o2->deleteLater(); }); } clang dumps different AST. In case of -std=c++14 (clang++ -std=c++14 -Xclang -ast-dump -c test.cpp) 3rd argument (lambda) passed to QObject::connect looks like this: CXXConstructExpr 0x5589e3278970 <line:14:21, col:46> '(lambda at test.cpp:14:21)':'(lambda at test.cpp:14:21)' 'void ((lambda at test.cpp:14:21) &&) noexcept' elidable `-MaterializeTemporaryExpr 0x5589e3275cd0 <col:21, col:46> '(lambda at test.cpp:14:21)' xvalue `-LambdaExpr in case of -std=c++17 lambda looks like this: `-LambdaExpr 0x5641f55db880 <line:14:21, col:46> '(lambda at test.cpp:14:21)' |-CXXRecordDecl 0x5641f55db420 <col:21> col:21 implicit class definition
Git commit bf9c81e8dda41c4a1202c93dbf85c4afef361ec2 by Sergio Martins. Committed on 05/05/2021 at 13:40. Pushed by smartins into branch 'master'. tests: Allow a test to specify that it wants c++17 M +12 -7 tests/run_tests.py https://invent.kde.org/sdk/clazy/commit/bf9c81e8dda41c4a1202c93dbf85c4afef361ec2
Git commit 2d3e842961b9d52e454c2c6838a30c630ba91492 by Sergio Martins. Committed on 05/05/2021 at 14:07. Pushed by smartins into branch 'master'. connect-3arg-lambda: Add a test that it still works with c++17 M +5 -0 tests/connect-3arg-lambda/config.json https://invent.kde.org/sdk/clazy/commit/2d3e842961b9d52e454c2c6838a30c630ba91492