summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/unusedfields.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-05-16 09:28:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-05-19 21:32:11 +0200
commit6ac83797e033dd0b799455d552c61abd202160b4 (patch)
tree4cb546067ea3d3c8f389c018b054418f5949da2c /compilerplugins/clang/unusedfields.cxx
parent2c244e6f533067d6c3affbd83759c71bc910ae99 (diff)
improve unusedfields loplugin to find constructor-only fields
ie. fields that are only touched in the constructor Change-Id: Ia714cbfed9710e47e69ca9f0eb0eac4f7e8b8a86 Reviewed-on: https://gerrit.libreoffice.org/54412 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/unusedfields.cxx')
-rw-r--r--compilerplugins/clang/unusedfields.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx
index 4095b23324c0..159d8544b635 100644
--- a/compilerplugins/clang/unusedfields.cxx
+++ b/compilerplugins/clang/unusedfields.cxx
@@ -67,6 +67,7 @@ bool operator < (const MyFieldInfo &lhs, const MyFieldInfo &rhs)
// try to limit the voluminous output a little
static std::set<MyFieldInfo> touchedFromInsideSet;
static std::set<MyFieldInfo> touchedFromOutsideSet;
+static std::set<MyFieldInfo> touchedFromOutsideConstructorSet;
static std::set<MyFieldInfo> readFromSet;
static std::set<MyFieldInfo> writeToSet;
static std::set<MyFieldInfo> definitionSet;
@@ -186,6 +187,8 @@ void UnusedFields::run()
output += "inside:\t" + s.parentClass + "\t" + s.fieldName + "\n";
for (const MyFieldInfo & s : touchedFromOutsideSet)
output += "outside:\t" + s.parentClass + "\t" + s.fieldName + "\n";
+ for (const MyFieldInfo & s : touchedFromOutsideConstructorSet)
+ output += "outside-constructor:\t" + s.parentClass + "\t" + s.fieldName + "\n";
for (const MyFieldInfo & s : readFromSet)
output += "read:\t" + s.parentClass + "\t" + s.fieldName + "\n";
for (const MyFieldInfo & s : writeToSet)
@@ -989,6 +992,8 @@ void UnusedFields::checkTouchedFromOutside(const FieldDecl* fieldDecl, const Exp
} else {
if (memberExprParentFunction->getParent() == fieldDecl->getParent()) {
touchedFromInsideSet.insert(fieldInfo);
+ if (!constructorDecl)
+ touchedFromOutsideConstructorSet.insert(fieldInfo);
} else {
touchedFromOutsideSet.insert(fieldInfo);
}