diff options
author | Sergio Martins <smartins@kde.org> | 2019-06-03 17:32:35 +0100 |
---|---|---|
committer | Sergio Martins <smartins@kde.org> | 2019-06-03 17:32:35 +0100 |
commit | 04d096386a149f09156ce78f0803f08cde8095b0 (patch) | |
tree | 9f8071d9d84514f2168103e60fa8c5fbe39af9bb /src | |
parent | 7763c1d33ea68a02b3db44feb2cd2b5bdb154bf0 (diff) |
signal-with-return-value: warn for by-ref signal arguments
For the same reason as return values
Diffstat (limited to 'src')
-rw-r--r-- | src/checks/manuallevel/signal-with-return-value.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/checks/manuallevel/signal-with-return-value.cpp b/src/checks/manuallevel/signal-with-return-value.cpp index 25884374..9c52079e 100644 --- a/src/checks/manuallevel/signal-with-return-value.cpp +++ b/src/checks/manuallevel/signal-with-return-value.cpp @@ -50,12 +50,16 @@ void SignalWithReturnValue::VisitDecl(clang::Decl *decl) return; const bool methodIsSignal = accessSpecifierManager->qtAccessSpecifierType(method) == QtAccessSpecifier_Signal; - if (!methodIsSignal) + if (!methodIsSignal || accessSpecifierManager->isScriptable(method)) return; - if (!method->getReturnType()->isVoidType()) { - if (!accessSpecifierManager->isScriptable(method)) { - emitWarning(decl, std::string(clazy::name(method)) + "() should return void. For a clean design signals shouldn't assume a single slot are connected to them."); + if (!method->getReturnType()->isVoidType()) + emitWarning(decl, std::string(clazy::name(method)) + "() should return void. For a clean design signals shouldn't assume a single slot are connected to them."); + + for (auto param : method->parameters()) { + QualType qt = param->getType(); + if (qt->isReferenceType() && !qt->getPointeeType().isConstQualified()) { + emitWarning(decl, std::string(clazy::name(method)) + "() shouldn't receive parameters by ref. For a clean design signals shouldn't assume a single slot are connected to them."); } } } |