Skip to content

Commit 410d978

Browse files
committed
Instrument comparisons inside comparisons
1 parent 58c366f commit 410d978

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

instrumenter.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,10 @@ func (i *instrumenter) visitExpr(exprPtr *ast.Expr) {
559559
if expr.Op.Precedence() == token.EQL.Precedence() {
560560
*exprPtr = i.wrap(expr)
561561
}
562-
// TODO: i.visitExpr(&expr.X)
563-
// TODO: i.visitExpr(&expr.Y)
562+
if expr.Op != token.LAND && expr.Op != token.LOR {
563+
i.visitExpr(&expr.X)
564+
i.visitExpr(&expr.Y)
565+
}
564566

565567
case *ast.KeyValueExpr:
566568
i.visitExpr(&expr.Key)

testdata/instrumenter/BinaryExpr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ func binaryExpr(i int, a bool, b bool) {
5555
i >= 34 && i <= 35
5656

5757
m := map[bool]int{}
58-
_ = m[i == 41] == m[i == 42] // TODO: instrument
58+
_ = m[i == 41] == m[i == 42]
5959
}

testdata/instrumenter/BinaryExpr.gobco

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func binaryExpr(i int, a bool, b bool) {
2727
gobcoCover(16, gobcoCover(21, i >= 34) && gobcoCover(22, i <= 35))
2828

2929
m := map[bool]int{}
30-
_ = gobcoCover(23, m[i == 41] == m[i == 42])
30+
_ = gobcoCover(23, m[gobcoCover(24, i == 41)] == m[gobcoCover(25, i == 42)])
3131
}
3232

3333
// :15:6: "i > 0"
@@ -54,3 +54,5 @@ func binaryExpr(i int, a bool, b bool) {
5454
// :55:3: "i >= 34"
5555
// :55:14: "i <= 35"
5656
// :58:6: "m[i == 41] == m[i == 42]"
57+
// :58:8: "i == 41"
58+
// :58:22: "i == 42"

0 commit comments

Comments
 (0)