Skip to content
Open
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: 4 additions & 3 deletions call.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,14 @@ func (c *calledFrom) succs(b *ssa.BasicBlock) bool {
return false
}

var called bool
for _, s := range b.Succs {
if !c.instrs(s.Instrs) && !c.succs(s) {
return false
if c.instrs(s.Instrs) || c.succs(s) {
called = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does not return immediately?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a defer function, the index of instr won't be 1.
So the loop will be returned before the Instruction was checked.
For an accurate validation, an iteration for "all of" s.Succs values is needed.

Copy link
Member

@tenntenn tenntenn Apr 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code only checks whether the function was called in any succsesors yet.
Because there is only an assignment which changes value of var called, called = true.

}
}

return true
return called
}

// CalledFrom checks whether receiver's method is called in an instruction
Expand Down