File tree Expand file tree Collapse file tree
test/query-tests/RedundantCode/DeadStoreOfLocal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737 def .getBasicBlock ( ) instanceof ReachableBasicBlock and
3838 // exclude assignments with default values or simple expressions
3939 not isSimple ( rhs ) and
40- // exclude variables that are not used at all
41- exists ( target .getAReference ( ) ) and
40+ // exclude variables that are not used in reachable code
41+ exists ( IR:: Instruction ref |
42+ ref != def and
43+ ( ref .reads ( target ) or ref .writes ( target , _) )
44+ ) and
4245 // exclude variables with indirect references
4346 not target .mayHaveIndirectReferences ( ) and
4447 // Report the assigned variable rather than the whole write instruction. A write to an
Original file line number Diff line number Diff line change 1- | main.go:36 :9:36 :9 | undefined: unknownFunction |
1+ | main.go:41 :9:41 :9 | undefined: unknownFunction |
Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ func deadParameter(x int) bool { // we don't want to flag x here
2626 return true
2727}
2828
29+ func usedOnlyAfterFalse () bool {
30+ s := deadStore ()
31+ return false && s == 0
32+ }
33+
2934func test2 (x int ) (int , int ) {
3035 y := x >> 5
3136 z := x % (1 )
You can’t perform that action at this time.
0 commit comments