diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-08-30 14:57:46 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-08-30 14:57:46 +0200 |
commit | 0660a30d54eb6762302cf1afd43de01e137f6393 (patch) | |
tree | 11f233dd05a17cd470f1d9bc5cf32e07f24df3ab /compilerplugins | |
parent | 67bff64e106a7b8192e73e3665474d4c4d1eb61a (diff) |
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
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/constparams.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx index 3203fc59cd12..31c1bc29affa 100644 --- a/compilerplugins/clang/constparams.cxx +++ b/compilerplugins/clang/constparams.cxx @@ -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); |