summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/constparams.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-08-30 12:22:19 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-08-30 12:22:19 +0200
commit99fb14ef729f9b92edcdd4bd7940d48fff6a7307 (patch)
tree7e16816ed235db0b7a98ce8b3fbecb0b6e91644f /compilerplugins/clang/constparams.cxx
parenteb08f19c73265e51f9192e65989be06277aef3dc (diff)
...in which Johnny returns from the fair
and finds loplugin:constparams adapted to ObjCMessageExpr Change-Id: I6e1ddd0fb1a8a61d5a78c156bccfc29f7233909e
Diffstat (limited to 'compilerplugins/clang/constparams.cxx')
-rw-r--r--compilerplugins/clang/constparams.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx
index bac52a422618..8c42e5a27c6b 100644
--- a/compilerplugins/clang/constparams.cxx
+++ b/compilerplugins/clang/constparams.cxx
@@ -186,6 +186,8 @@ bool ConstParams::VisitFunctionDecl(const FunctionDecl * functionDecl)
|| name == "egiGraphicExport"
|| name == "etiGraphicExport"
|| name == "epsGraphicExport"
+ || name == "QueueCallbackFunction"
+ // apple_remote/source/HIDRemoteControlDevice.m
)
return true;
}
@@ -392,6 +394,24 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar
}
}
return false; // TODO ????
+ } else if (auto callExpr = dyn_cast<ObjCMessageExpr>(parent)) {
+ if (callExpr->getInstanceReceiver() == stmt) {
+ return true;
+ }
+ if (auto const method = callExpr->getMethodDecl()) {
+ // TODO could do better
+ if (method->isVariadic()) {
+ return false;
+ }
+ assert(method->param_size() == callExpr->getNumArgs());
+ for (unsigned i = 0; i < callExpr->getNumArgs(); ++i) {
+ if (callExpr->getArg(i) == stmt) {
+ return isPointerOrReferenceToConst(
+ method->param_begin()[i]->getType());
+ }
+ }
+ }
+ return false; // TODO ????
} else if (isa<CXXReinterpretCastExpr>(parent)) {
return false;
} else if (isa<CXXConstCastExpr>(parent)) {