[zeek/spicy] aef172: Link free-function implementations to their protot...

0 views
Skip to first unread message

Benjamin Bannier

unread,
Jun 26, 2026, 9:49:08 AM (8 days ago) Jun 26
to spicy-...@zeek.org
Branch: refs/heads/topic/robin/gh-2325-canon-ids
Home: https://github.com/zeek/spicy
Commit: aef172c2bfa740f41325b2759742b80bcd0c3a4c
https://github.com/zeek/spicy/commit/aef172c2bfa740f41325b2759742b80bcd0c3a4c
Author: Robin Sommer <ro...@corelight.com>
Date: 2026-06-26 (Fri, 26 Jun 2026)

Changed paths:
M hilti/toolchain/src/compiler/resolver.cc

Log Message:
-----------
Link free-function implementations to their prototypes.

When a free function is declared separately from its implementation,
the resolver now links the implementation to its prototype.
Previously, we did this only for methods, which means AST consumers
had to handle free functions themselves.


Commit: 09c092a9733e77d4bd6d9b1b1fe7437ee1607e4b
https://github.com/zeek/spicy/commit/09c092a9733e77d4bd6d9b1b1fe7437ee1607e4b
Author: Robin Sommer <ro...@corelight.com>
Date: 2026-06-26 (Fri, 26 Jun 2026)

Changed paths:
M hilti/toolchain/include/ast/declarations/function.h
M hilti/toolchain/include/compiler/detail/optimizer/optimizer.h
M hilti/toolchain/src/ast/declarations/function.cc
M hilti/toolchain/src/compiler/optimizer/passes/dead-code-static.cc
M hilti/toolchain/src/compiler/optimizer/passes/propagate-function-returns.cc
M hilti/toolchain/src/compiler/optimizer/passes/remove-unused-fields.cc
M hilti/toolchain/src/compiler/optimizer/passes/remove-unused-params.cc

Log Message:
-----------
Inside optimizer, index per-function state by canonical ID.

We were using `fullyQualifiedId()`, which isn't unique across module
imports: separate functions can have the same FQID inside a single
AST.

To facilitate the switch, we replace
`declaration::Function::functionID()` with ``Optimizer::functionID()`
that returns a function/method's canonical ID but follows any linked
declarations to its prototype before doing so. That way, it returns an
ID that's suitable to use as an index inside optimizer passes to store
state per function.

We then use that consistently across the optimizer.

Couple related tweaks included:

- `dead-code-static` now resolves `MemberCall` targets via
`op.declaration()` instead of `type::Struct::field(id)`, which only
returned the first matching field and masked overload bugs.

- `remove-unused-params` skips parameter removal when a struct has
overloaded methods of the same name, since stripping unused
parameters under canonical ID keys can collapse overloads to
identical signatures.


Compare: https://github.com/zeek/spicy/compare/516f9871b427...09c092a9733e

To unsubscribe from these emails, change your notification settings at https://github.com/zeek/spicy/settings/notifications

Benjamin Bannier

unread,
Jun 26, 2026, 11:41:24 AM (8 days ago) Jun 26
to spicy-...@zeek.org
Branch: refs/heads/main
Commit: d99aa5248bc19354aa271400c1756e464f6b4de2
https://github.com/zeek/spicy/commit/d99aa5248bc19354aa271400c1756e464f6b4de2
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2026-06-26 (Fri, 26 Jun 2026)

Changed paths:
M CHANGES
M VERSION
M hilti/toolchain/include/ast/declarations/function.h
M hilti/toolchain/include/compiler/detail/optimizer/optimizer.h
M hilti/toolchain/src/ast/declarations/function.cc
M hilti/toolchain/src/compiler/optimizer/passes/dead-code-static.cc
M hilti/toolchain/src/compiler/optimizer/passes/propagate-function-returns.cc
M hilti/toolchain/src/compiler/optimizer/passes/remove-unused-fields.cc
M hilti/toolchain/src/compiler/optimizer/passes/remove-unused-params.cc
M hilti/toolchain/src/compiler/resolver.cc

Log Message:
-----------
Merge remote-tracking branch 'origin/topic/robin/gh-2325-canon-ids'


Compare: https://github.com/zeek/spicy/compare/6822ca1ab947...d99aa5248bc1
Reply all
Reply to author
Forward
0 new messages