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 56
56
not isExcluded ( v , DeadCodePackage:: unusedLocalVariableQuery ( ) ) and
57
57
// Local variable is never accessed
58
58
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
59
67
getUseCountConservatively ( v ) = 0
60
68
select 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 {
52
52
// exclude uninstantiated template members
53
53
not this .isFromUninstantiatedTemplate ( _) and
54
54
// 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 ( )
61
56
}
62
57
}
63
58
You can’t perform that action at this time.
0 commit comments