summaryrefslogtreecommitdiffstats
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-11-02 14:32:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-11-03 07:54:12 +0100
commit6299c8cae923198c55d47320fa8a89bbcd5b0f2b (patch)
tree019ed8f1d754f92fb72c9ae4639ab671bae97018 /compilerplugins
parentAvoid float-cast-overflow (diff)
downloadcore-6299c8cae923198c55d47320fa8a89bbcd5b0f2b.tar.gz
core-6299c8cae923198c55d47320fa8a89bbcd5b0f2b.zip
loplugin:constparams
Change-Id: Iebeb531fad5cc819b536788925cf8508737198b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124599 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/constparams.cxx20
1 files changed, 11 insertions, 9 deletions
diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx
index b7c13750eb5b..950ae91e0b27 100644
--- a/compilerplugins/clang/constparams.cxx
+++ b/compilerplugins/clang/constparams.cxx
@@ -291,9 +291,11 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar
{
// check if we're inside a CXXCtorInitializer
auto parentsRange = compiler.getASTContext().getParents(*stmt);
+ auto it = parentsRange.begin();
if ( parentsRange.begin() != parentsRange.end())
{
- if (auto cxxConstructorDecl = dyn_cast_or_null<CXXConstructorDecl>(parentsRange.begin()->get<Decl>()))
+ const Decl *decl = it->get<Decl>();
+ if (auto cxxConstructorDecl = dyn_cast_or_null<CXXConstructorDecl>(decl))
{
for ( auto cxxCtorInitializer : cxxConstructorDecl->inits())
{
@@ -317,18 +319,18 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar
}
}
}
- if (auto varDecl = dyn_cast_or_null<VarDecl>(parentsRange.begin()->get<Decl>()))
+ if (auto varDecl = dyn_cast_or_null<VarDecl>(decl))
{
return isOkForParameter(varDecl->getType());
}
}
- parmVarDecl->dump();
- stmt->dump();
- report(
- DiagnosticsEngine::Warning,
- "no parent?",
- compat::getBeginLoc(stmt))
- << stmt->getSourceRange();
+// parmVarDecl->dump();
+// stmt->dump();
+// report(
+// DiagnosticsEngine::Warning,
+// "no parent?",
+// compat::getBeginLoc(stmt))
+// << stmt->getSourceRange();
return false;
}