diff options
Diffstat (limited to 'compilerplugins/clang/constparams.cxx')
-rw-r--r-- | compilerplugins/clang/constparams.cxx | 20 |
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)) { |