Skip to content

Commit 22d0902

Browse files
committed
Include receivers in parameter init
1 parent 4f26b7c commit 22d0902

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,8 +1488,9 @@ module GoCfg {
14881488

14891489
/**
14901490
* Function definition prologue and epilogue:
1491-
* - Prologue: Before(fd) → arg:0 → param-init:0 → arg:1 → param-init:1 → ...
1492-
* → result-zero-init:0 → result-init:0 → ... → Before(body)
1491+
* - Prologue: Before(fd) → arg:-1 → param-init:-1 → arg:0 → param-init:0 → ...
1492+
* when a receiver exists; otherwise it starts at arg:0. Then
1493+
* result-zero-init:0 → result-init:0 → ... → Before(body)
14931494
* - Epilogue: After(body) → result-read:0 → result-read:1 → ... → After(fd)
14941495
*
14951496
* `After(fd)` goes to `NormalExit(fd)` via the shared library's built-in step
@@ -1500,8 +1501,13 @@ module GoCfg {
15001501
// Before(fd) → first prologue node, or Before(body) if no prologue
15011502
n1.isBefore(fd) and
15021503
(
1503-
// Has parameters: start with arg:0
1504-
exists(fd.getParameter(0)) and n2.isAdditional(fd, "arg:0")
1504+
// Has receiver: start with arg:-1
1505+
exists(fd.getParameter(-1)) and n2.isAdditional(fd, "arg:-1")
1506+
or
1507+
// Has ordinary parameters: start with arg:0
1508+
not exists(fd.getParameter(-1)) and
1509+
exists(fd.getParameter(0)) and
1510+
n2.isAdditional(fd, "arg:0")
15051511
or
15061512
// No parameters, has result vars: start with result-zero-init:0
15071513
not exists(fd.getParameter(_)) and

0 commit comments

Comments
 (0)