summaryrefslogtreecommitdiffstats
path: root/compilerplugins/clang/unusedmethods.py
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-11-21 15:36:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-11-22 08:34:16 +0200
commit6f9cdf0814c8364ee6000075f8c04bc7fa2e51f8 (patch)
tree54a7ce9833a382fa22aae19c8859ecc00401e91d /compilerplugins/clang/unusedmethods.py
parentRemove excessive parenthesis. (diff)
downloadcore-6f9cdf0814c8364ee6000075f8c04bc7fa2e51f8.tar.gz
core-6f9cdf0814c8364ee6000075f8c04bc7fa2e51f8.zip
can-be-private analysis needs to ignore virtual methods
Change-Id: I1e2f28ed550ff9751912f70e3eec511ddc5b75cf
Diffstat (limited to 'compilerplugins/clang/unusedmethods.py')
-rwxr-xr-xcompilerplugins/clang/unusedmethods.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/compilerplugins/clang/unusedmethods.py b/compilerplugins/clang/unusedmethods.py
index bf05c2fdf739..53cc93495555 100755
--- a/compilerplugins/clang/unusedmethods.py
+++ b/compilerplugins/clang/unusedmethods.py
@@ -17,6 +17,7 @@ callSet = set() # set of tuple(return_type, name_and_params)
# 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)
+virtualSet = set() # set of tuple(return_type, name_and_params)
# for the "unused return types" analysis
usedReturnSet = set() # set of tuple(return_type, name_and_params)
@@ -114,11 +115,15 @@ with io.open("loplugin.unusedmethods.log", "rb", buffering=1024*1024) as txt:
returnType = tokens[2]
nameAndParams = tokens[3]
sourceLocation = tokens[4]
+ virtual = ""
+ if len(tokens)>=6: virtual = tokens[5]
funcInfo = (normalizeTypeParams(returnType), normalizeTypeParams(nameAndParams))
definitionSet.add(funcInfo)
if access == "public":
publicDefinitionSet.add(funcInfo)
definitionToSourceLocationMap[funcInfo] = sourceLocation
+ if virtual == "virtual":
+ virtualSet.add(funcInfo)
elif tokens[0] == "call:":
returnType = tokens[1]
nameAndParams = tokens[2]
@@ -333,6 +338,8 @@ for d in publicDefinitionSet:
method = d[0] + " " + d[1]
if d in calledFromOutsideSet:
continue
+ if d in virtualSet:
+ continue
# TODO ignore constructors for now, my called-from-outside analysis doesn't work here
if d[0] == "":
continue