Avoid loplugin:constparam when param is subject of cast to non-const pointer

...as in WriteCallback (desktop/source/minidump/minidump.cxx), where

  void *ptr

is use in

  static_cast<char *>(ptr)

Change-Id: I0bd44329029cd793390d0744de3c839612e0b494
This commit is contained in:
Stephan Bergmann
2017-08-30 14:57:46 +02:00
parent 67bff64e10
commit 0660a30d54

View File

@@ -418,6 +418,12 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar
} else if (isa<CXXConstCastExpr>(parent)) {
return false;
} else if (isa<CastExpr>(parent)) { // all other cast expression subtypes
if (auto e = dyn_cast<ExplicitCastExpr>(parent)) {
if (loplugin::TypeCheck(e->getTypeAsWritten()).Pointer().NonConst())
{
return false;
}
}
return checkIfCanBeConst(parent, parmVarDecl);
} else if (isa<MemberExpr>(parent)) {
return checkIfCanBeConst(parent, parmVarDecl);