summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/unusedmethods.py
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/unusedmethods.py')
-rwxr-xr-xcompilerplugins/clang/unusedmethods.py41
1 files changed, 7 insertions, 34 deletions
diff --git a/compilerplugins/clang/unusedmethods.py b/compilerplugins/clang/unusedmethods.py
index 41044d37f5ef..1e2a67424dd6 100755
--- a/compilerplugins/clang/unusedmethods.py
+++ b/compilerplugins/clang/unusedmethods.py
@@ -14,7 +14,7 @@ definitionToSourceLocationMap = dict()
# for the "unused methods" analysis
callSet = set() # set of tuple(return_type, name_and_params)
-# for the "unnecessary public" analysis
+# for the "method can be private" analysis
publicDefinitionSet = set() # set of tuple(return_type, name_and_params)
calledFromOutsideSet = set() # set of tuple(return_type, name_and_params)
@@ -25,23 +25,6 @@ usedReturnSet = set() # set of tuple(return_type, name_and_params)
# things we need to exclude for reasons like :
# - it's a weird template thingy that confuses the plugin
unusedMethodsExclusionSet = set([
- "double basegfx::DoubleTraits::maxVal()",
- "double basegfx::DoubleTraits::minVal()",
- "double basegfx::DoubleTraits::neutral()",
- "int basegfx::Int32Traits::maxVal()",
- "int basegfx::Int32Traits::minVal()",
- "int basegfx::Int32Traits::neutral()",
- "unsigned long UniqueIndexImpl::Insert(void *)",
- "class XMLPropertyBackpatcher<short> & XMLTextImportHelper::GetFootnoteBP()",
- "class XMLPropertyBackpatcher<short> & XMLTextImportHelper::GetSequenceIdBP()",
- "void XclExpPivotCache::SaveXml(class XclExpXmlStream &)",
-
-
- # TODO track instantiations of template class constructors
- "void comphelper::IEventProcessor::release()",
- "void SotMutexHolder::acquire()",
- "void SotMutexHolder::release()",
-
# only used by Windows build
"_Bool basegfx::B2ITuple::equalZero() const",
"class basegfx::B2DPolyPolygon basegfx::unotools::UnoPolyPolygon::getPolyPolygonUnsafe() const",
@@ -72,10 +55,6 @@ unusedMethodsExclusionSet = set([
"_Bool ScImportExport::ImportData(const class rtl::OUString &,const class com::sun::star::uno::Any &)",
"void* ScannerManager::GetData()",
"void ScannerManager::SetData(void *)",
- # instantiated from templates, not sure why it is not being picked up
- "class basegfx::B2DPolygon OutputDevice::PixelToLogic(const class basegfx::B2DPolygon &,const class MapMode &) const",
- "type-parameter-0-0 * detail::cloner::clone(type-parameter-0-0 *const)",
- "const class rtl::OUString writerperfect::DocumentHandlerFor::name()",
# only used by OSX build
"void StyleSettings::SetHideDisabledMenuItems(_Bool)",
# debugging methods
@@ -83,12 +62,6 @@ unusedMethodsExclusionSet = set([
"void oox::PropertyMap::dumpCode(class com::sun::star::uno::Reference<class com::sun::star::beans::XPropertySet>)",
"void oox::PropertyMap::dumpData(class com::sun::star::uno::Reference<class com::sun::star::beans::XPropertySet>)",
"class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > writerfilter::ooxml::OOXMLPropertySet::toString()",
- # deep template magic in SW
- "Ring<value_type> * sw::Ring::Ring_node_traits::get_next(const Ring<value_type> *)",
- "Ring<value_type> * sw::Ring::Ring_node_traits::get_previous(const Ring<value_type> *)",
- "void sw::Ring::Ring_node_traits::set_next(Ring<value_type> *,Ring<value_type> *)",
- "void sw::Ring::Ring_node_traits::set_previous(Ring<value_type> *,Ring<value_type> *)",
- "type-parameter-0-0 checking_cast(type-parameter-0-0,type-parameter-0-0)",
# I need to teach the plugin that for loops with range expressions call begin() and end()
"class __gnu_debug::_Safe_iterator<class __gnu_cxx::__normal_iterator<class SwAnchoredObject *const *, class std::__cxx1998::vector<class SwAnchoredObject *, class std::allocator<class SwAnchoredObject *> > >, class std::__debug::vector<class SwAnchoredObject *, class std::allocator<class SwAnchoredObject *> > > SwSortedObjs::begin() const",
"class __gnu_debug::_Safe_iterator<class __gnu_cxx::__normal_iterator<class SwAnchoredObject *const *, class std::__cxx1998::vector<class SwAnchoredObject *, class std::allocator<class SwAnchoredObject *> > >, class std::__debug::vector<class SwAnchoredObject *, class std::allocator<class SwAnchoredObject *> > > SwSortedObjs::end() const",
@@ -158,6 +131,8 @@ with io.open("loplugin.unusedmethods.log", "rb", buffering=1024*1024) as txt:
returnType = tokens[1]
nameAndParams = tokens[2]
calledFromOutsideSet.add((normalizeTypeParams(returnType), normalizeTypeParams(nameAndParams)))
+ else:
+ print( "unknown line: " + line)
# Invert the definitionToSourceLocationMap.
# If we see more than one method at the same sourceLocation, it's being autogenerated as part of a template
@@ -283,7 +258,7 @@ for d in definitionSet:
tmp1set.add((method, location))
# print out the results, sorted by name and line number
-with open("loplugin.unusedmethods.report-methods", "wt") as f:
+with open("loplugin.unusedmethods.report-unused-methods", "wt") as f:
for t in sort_set_by_natural_key(tmp1set):
f.write(t[1] + "\n")
f.write(" " + t[0] + "\n")
@@ -343,14 +318,14 @@ for d in definitionSet:
tmp2set.add((method, location))
# print output, sorted by name and line number
-with open("loplugin.unusedmethods.report-returns", "wt") as f:
+with open("loplugin.unusedmethods.report-unused-returns", "wt") as f:
for t in sort_set_by_natural_key(tmp2set):
f.write(t[1] + "\n")
f.write(" " + t[0] + "\n")
# --------------------------------------------------------------------------------------------
-# "unnecessary public" analysis
+# "method can be private" analysis
# --------------------------------------------------------------------------------------------
tmp3set = set()
@@ -366,10 +341,8 @@ for d in publicDefinitionSet:
tmp3set.add((method, definitionToSourceLocationMap[d]))
# print output, sorted by name and line number
-with open("loplugin.unusedmethods.report-public", "wt") as f:
+with open("loplugin.unusedmethods.report-can-be-private", "wt") as f:
for t in sort_set_by_natural_key(tmp3set):
f.write(t[1] + "\n")
f.write(" " + t[0] + "\n")
-
-