summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-18 09:43:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-18 16:02:25 +0200
commit65ae6af9f460b1a28f3e07480347ff7f90adae38 (patch)
tree49bfeb1e25724d3b5539b7b5843d38b7531cf65f /compilerplugins
parentc7d1bb119d88faaafb53d65ad8907ede97d89c8c (diff)
loplugin:unusedvarsglobal
tackle some read-only vars. Mark some of them const to make it obvious they are not really used, and to make the constantparam plugin see more data. Change-Id: Ia25927745866746aa1aa9d5affd5857ad9f9ee24 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100895 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/unusedvarsglobal.cxx4
-rwxr-xr-xcompilerplugins/clang/unusedvarsglobal.py31
2 files changed, 34 insertions, 1 deletions
diff --git a/compilerplugins/clang/unusedvarsglobal.cxx b/compilerplugins/clang/unusedvarsglobal.cxx
index e5ca57c4ba5a..4619bd3617c5 100644
--- a/compilerplugins/clang/unusedvarsglobal.cxx
+++ b/compilerplugins/clang/unusedvarsglobal.cxx
@@ -243,6 +243,8 @@ bool UnusedVarsGlobal::VisitVarDecl(const VarDecl* varDecl)
return true;
if (varDecl->isConstexpr())
return true;
+ if (varDecl->isExceptionVariable())
+ return true;
if (!varDecl->getLocation().isValid() || ignoreLocation(varDecl))
return true;
// ignore stuff that forms part of the stable URE interface
@@ -267,6 +269,8 @@ bool UnusedVarsGlobal::VisitDeclRefExpr(const DeclRefExpr* declRefExpr)
return true;
if (varDecl->isConstexpr())
return true;
+ if (varDecl->isExceptionVariable())
+ return true;
varDecl = varDecl->getCanonicalDecl();
if (!varDecl->getLocation().isValid() || ignoreLocation(varDecl))
return true;
diff --git a/compilerplugins/clang/unusedvarsglobal.py b/compilerplugins/clang/unusedvarsglobal.py
index 1231edf9bd18..cfc83ad7e8f4 100755
--- a/compilerplugins/clang/unusedvarsglobal.py
+++ b/compilerplugins/clang/unusedvarsglobal.py
@@ -65,7 +65,13 @@ for d in definitionSet:
continue
if vartype in ["OpenCLInitialZone", "pyuno::PyThreadDetach", "SortRefUpdateSetter", "oglcanvas::TransformationPreserver"]:
continue
- if vartype in ["StackHack"]:
+ if vartype in ["StackHack", "osl::MutexGuard", "accessibility::SolarMethodGuard"]:
+ continue
+ if vartype in ["osl::ClearableMutexGuard", "comphelper::OExternalLockGuard", "osl::Guard< ::osl::Mutex>"]:
+ continue
+ if vartype in ["comphelper::OContextEntryGuard", "Guard<class osl::Mutex>", "basic::LibraryContainerMethodGuard"]:
+ continue
+ if vartype in ["canvas::CanvasBase::MutexType"]:
continue
definitionSet2.add(d)
@@ -83,12 +89,35 @@ writeonlySet = set()
for d in definitionSet2:
if d in readFromSet or d in untouchedSet:
continue
+ varname = d[1]
+ vartype = defToTypeMap[d]
+ if "Alive" in varname:
+ continue
+ if "Keep" in varname:
+ continue
+ if vartype.endswith(" &"):
+ continue
writeonlySet.add(d)
readonlySet = set()
for d in definitionSet2:
if d in writeToSet or d in untouchedSet:
continue
+ varname = d[1]
+ vartype = defToTypeMap[d]
+ if "Dummy" in varname:
+ continue
+ if "Empty" in varname:
+ continue
+ if varname in ["aOldValue", "aNewValue"]:
+ continue
+ if "Exception" in vartype and vartype.endswith(" &"):
+ continue
+ if "exception" in vartype and vartype.endswith(" &"):
+ continue
+ # TODO for now, focus on the simple stuff
+ if not (vartype in ["rtl::OUString", "Bool"]):
+ continue
readonlySet.add(d)
# sort the results using a "natural order" so sequences like [item1,item2,item10] sort nicely