summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/unusedfields.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/unusedfields.cxx')
-rw-r--r--compilerplugins/clang/unusedfields.cxx21
1 files changed, 20 insertions, 1 deletions
diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx
index 471ecee97410..fb1a16a0c13f 100644
--- a/compilerplugins/clang/unusedfields.cxx
+++ b/compilerplugins/clang/unusedfields.cxx
@@ -447,11 +447,30 @@ bool UnusedFields::TraverseIfStmt(IfStmt* ifStmt)
{
FieldDecl const * memberFieldDecl = nullptr;
Expr const * cond = ifStmt->getCond()->IgnoreParenImpCasts();
- if (auto memberExpr = dyn_cast<MemberExpr>(cond))
+
+ if (auto memberCallExpr = dyn_cast<CXXMemberCallExpr>(cond))
+ {
+ if (auto cxxConvert = dyn_cast_or_null<CXXConversionDecl>(memberCallExpr->getMethodDecl()))
+ {
+ if (cxxConvert->getConversionType()->isBooleanType())
+ if (auto memberExpr = dyn_cast<MemberExpr>(memberCallExpr->getImplicitObjectArgument()->IgnoreParenImpCasts()))
+ if ((memberFieldDecl = dyn_cast<FieldDecl>(memberExpr->getMemberDecl())))
+ insideConditionalCheckOfMemberSet.push_back(memberFieldDecl);
+ }
+ else if (auto cxxMethod = memberCallExpr->getMethodDecl())
+ {
+ if (cxxMethod->getIdentifier() && cxxMethod->getName() == "get" && memberCallExpr->getNumArgs()==0)
+ if (auto memberExpr = dyn_cast<MemberExpr>(memberCallExpr->getImplicitObjectArgument()->IgnoreParenImpCasts()))
+ if ((memberFieldDecl = dyn_cast<FieldDecl>(memberExpr->getMemberDecl())))
+ insideConditionalCheckOfMemberSet.push_back(memberFieldDecl);
+ }
+ }
+ else if (auto memberExpr = dyn_cast<MemberExpr>(cond))
{
if ((memberFieldDecl = dyn_cast<FieldDecl>(memberExpr->getMemberDecl())))
insideConditionalCheckOfMemberSet.push_back(memberFieldDecl);
}
+
bool ret = RecursiveASTVisitor::TraverseIfStmt(ifStmt);
if (memberFieldDecl)
insideConditionalCheckOfMemberSet.pop_back();