This repository was archived by the owner on Jan 5, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
test/query-tests/RedundantCode/CompareIdenticalValues Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ class SsaSourceVariable extends LocalVariable {
2424 // variables that have their address taken
2525 exists ( AddressExpr addr | addr .getOperand ( ) .stripParens ( ) = getAUse ( ) )
2626 or
27+ exists ( DataFlow:: MethodReadNode mrn |
28+ mrn .getReceiver ( ) = getARead ( ) and
29+ mrn .getMethod ( ) .getReceiverType ( ) instanceof PointerType
30+ )
31+ or
2732 // variables where there is an unresolved reference with the same name in the same
2833 // scope or a nested scope, suggesting that name resolution information may be incomplete
2934 exists ( FunctionScope scope , FuncDef inner |
Original file line number Diff line number Diff line change 11| CompareIdenticalValues.go:9:3:9:8 | ...<=... | This expression compares $@ to itself. | CompareIdenticalValues.go:9:3:9:3 | y | an expression |
22| tst.go:6:9:6:14 | ...==... | This expression compares $@ to itself. | tst.go:6:9:6:9 | x | an expression |
3+ | tst.go:60:9:60:14 | ...==... | This expression compares $@ to itself. | tst.go:60:9:60:9 | y | an expression |
34| vp.go:16:9:16:38 | ...!=... | This expression compares $@ to itself. | vp.go:16:9:16:21 | call to GetLength | an expression |
Original file line number Diff line number Diff line change @@ -37,3 +37,25 @@ func baz() bool {
3737 bump (& x )
3838 return x == 0
3939}
40+
41+ type counter int
42+
43+ func (x * counter ) bump () {
44+ * x ++
45+ }
46+
47+ func (x counter ) bimp () {
48+ x ++
49+ }
50+
51+ func baz2 () bool {
52+ var x counter
53+ x .bump ()
54+ return x == 0 // OK
55+ }
56+
57+ func baz3 () bool {
58+ var y counter
59+ y .bimp ()
60+ return y == 0 // NOT OK
61+ }
You can’t perform that action at this time.
0 commit comments