Kaydet (Commit) 99fb14ef authored tarafından Stephan Bergmann's avatar Stephan Bergmann

...in which Johnny returns from the fair

and finds loplugin:constparams adapted to ObjCMessageExpr

Change-Id: I6e1ddd0fb1a8a61d5a78c156bccfc29f7233909e
üst eb08f19c
......@@ -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)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment