Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions go/ql/src/RedundantCode/DeadStoreOfLocal.ql
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ where
def.getBasicBlock() instanceof ReachableBasicBlock and
// exclude assignments with default values or simple expressions
not isSimple(rhs) and
// exclude variables that are not used at all
exists(target.getAReference()) and
// exclude variables that are not used in reachable code
exists(IR::Instruction ref |
ref != def and
(ref.reads(target) or ref.writes(target, _))
) and
// exclude variables with indirect references
not target.mayHaveIndirectReferences() and
// Report the assigned variable rather than the whole write instruction. A write to an
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
| main.go:36:9:36:9 | undefined: unknownFunction |
| main.go:41:9:41:9 | undefined: unknownFunction |
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func deadParameter(x int) bool { // we don't want to flag x here
return true
}

func usedOnlyAfterFalse() bool {
s := deadStore()
return false && s == 0
}

func test2(x int) (int, int) {
y := x >> 5
z := x % (1)
Expand Down
Loading