diff options
author | Noel Grandin <noel@peralex.com> | 2016-06-28 14:52:54 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-06-28 14:53:17 +0200 |
commit | 442dd6a153385d7c2826eabe0737d4d53332f392 (patch) | |
tree | e16a8a31526551de1f6810a0c22a6ac898231bf4 /compilerplugins/clang/unusedfields.cxx | |
parent | e3e79246cb7dd28a8b3511cefd0c41cf19b3e7de (diff) |
loplugin: move parentFunctionDecl() into common code
Change-Id: Ia10a76a98a63c6ea3b516d9146281f672b213ab3
Diffstat (limited to 'compilerplugins/clang/unusedfields.cxx')
-rw-r--r-- | compilerplugins/clang/unusedfields.cxx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx index 81745117c7a7..03bd3dbbf18e 100644 --- a/compilerplugins/clang/unusedfields.cxx +++ b/compilerplugins/clang/unusedfields.cxx @@ -210,8 +210,15 @@ bool UnusedFields::VisitMemberExpr( const MemberExpr* memberExpr ) if (!fieldDecl) { return true; } + MyFieldInfo fieldInfo = niceName(fieldDecl); - touchedSet.insert(fieldInfo); + + // ignore move/copy operator, it's self->self + const FunctionDecl* parentFunction = parentFunctionDecl(memberExpr); + const CXXMethodDecl* methodDecl = dyn_cast_or_null<CXXMethodDecl>(parentFunction); + if (!methodDecl || !(methodDecl->isCopyAssignmentOperator() || methodDecl->isMoveAssignmentOperator())) { + touchedSet.insert(fieldInfo); + } // for the write-only analysis |