diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-08-31 12:13:15 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-08-31 12:14:41 +0200 |
commit | 6d57d6c40f15dfcf3c367687aaca5e144ba1e746 (patch) | |
tree | dd6a41249778bcdcad1be2c3397f382abfa77614 /compilerplugins/clang/constparams.cxx | |
parent | 9a81c6933b829e511c3c61e2ae4205c04e577e4b (diff) |
Adapt lopluign:constparams to variadic CXXOperatorCallExpr
Change-Id: I21c7a0fb447b5ba0a7aa0ddc690b969b156a91f3
Diffstat (limited to 'compilerplugins/clang/constparams.cxx')
-rw-r--r-- | compilerplugins/clang/constparams.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx index 9c2263c87453..50e1c98bfc3c 100644 --- a/compilerplugins/clang/constparams.cxx +++ b/compilerplugins/clang/constparams.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <algorithm> #include <string> #include <unordered_set> #include <unordered_map> @@ -328,7 +329,10 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar if (operatorCallExpr->getArg(0) == stmt) { return calleeMethodDecl->isConst(); } - for (unsigned i = 1; i < operatorCallExpr->getNumArgs(); ++i) + unsigned const n = std::min( + operatorCallExpr->getNumArgs(), + calleeMethodDecl->getNumParams()); + for (unsigned i = 1; i < n; ++i) if (operatorCallExpr->getArg(i) == stmt) { return isPointerOrReferenceToConst(calleeMethodDecl->getParamDecl(i - 1)->getType()); } |