File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
common/src/codingstandards/cpp/deadcode Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 5656 not isExcluded ( v , DeadCodePackage:: unusedLocalVariableQuery ( ) ) and
5757 // Local variable is never accessed
5858 not exists ( v .getAnAccess ( ) ) and
59+ // Sometimes multiple objects representing the same entities are created in
60+ // the AST. Check if those are not accessed as well. Refer issue #658
61+ not exists ( LocalScopeVariable another |
62+ another .getDefinitionLocation ( ) = v .getDefinitionLocation ( ) and
63+ another .hasName ( v .getName ( ) ) and
64+ exists ( another .getAnAccess ( ) ) and
65+ another != v
66+ ) and
5967 getUseCountConservatively ( v ) = 0
6068select v , "Local variable '" + v .getName ( ) + "' in '" + v .getFunction ( ) .getName ( ) + "' is not used."
Original file line number Diff line number Diff line change @@ -52,12 +52,7 @@ class PotentiallyUnusedLocalVariable extends LocalVariable {
5252 // exclude uninstantiated template members
5353 not this .isFromUninstantiatedTemplate ( _) and
5454 // Do not report compiler generated variables
55- not this .isCompilerGenerated ( ) and
56- not exists ( LocalScopeVariable another |
57- another .getDefinitionLocation ( ) = this .getDefinitionLocation ( ) and
58- another .hasName ( this .getName ( ) ) and
59- exists ( another .getAnAccess ( ) )
60- )
55+ not this .isCompilerGenerated ( )
6156 }
6257}
6358
You can’t perform that action at this time.
0 commit comments