diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-18 11:08:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-18 14:59:47 +0200 |
commit | 3964408f7f6acbfe613c6173f44c810fdacdc63d (patch) | |
tree | 0b3522e9f079b353b5946dbc7a4772bf42bd9deb /compilerplugins | |
parent | e56596e009c11ec6118a126ac560e87d754ae15b (diff) |
loplugin:constparams in sdext
Change-Id: Ia5d2c00b02bf1758f7502065dd109f0f54fda2d3
Reviewed-on: https://gerrit.libreoffice.org/40124
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/constparams.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx index 9fbea42bdd44..3fc5928c9589 100644 --- a/compilerplugins/clang/constparams.cxx +++ b/compilerplugins/clang/constparams.cxx @@ -360,13 +360,14 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar } else if (isa<UnaryExprOrTypeTraitExpr>(parent)) { return false; // ??? } else if (isa<CXXNewExpr>(parent)) { - return true; // because the ParamVarDecl must be a parameter to the expression, probably an array count + return true; // because the ParamVarDecl must be a parameter to the expression, probably an array length } else if (auto lambdaExpr = dyn_cast<LambdaExpr>(parent)) { for (auto it = lambdaExpr->capture_begin(); it != lambdaExpr->capture_end(); ++it) { - if (it->getCapturedVar() == parmVarDecl) + if (it->capturesVariable() && it->getCapturedVar() == parmVarDecl) return it->getCaptureKind() != LCK_ByRef; } + /* sigh. just running this message will cause clang to crash (in sdext) report( DiagnosticsEngine::Warning, "cannot handle this lambda", @@ -374,14 +375,18 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar << parent->getSourceRange(); parent->dump(); parmVarDecl->dump(); + */ + return false; + } else if (isa<CXXTypeidExpr>(parent)) { + return true; } else { + parent->dump(); + parmVarDecl->dump(); report( DiagnosticsEngine::Warning, "oh dear, what can the matter be?", parent->getLocStart()) << parent->getSourceRange(); - parent->dump(); - parmVarDecl->dump(); } return true; } |