Refactor: Move resolvedLinkage from AST to Semantic layer#22597
Refactor: Move resolvedLinkage from AST to Semantic layer#22597Adityazzzzz wants to merge 1 commit intodlang:masterfrom
Conversation
This decouples the Declaration AST node from target-specific semantic checks and enables further cleanup of func.d and the backend glue code.
|
Thanks for your pull request and interest in making D better, @Adityazzzzz! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#22597" |
|
@RazvanN7 I've started tackling the 'intricate solutions' for the Separate Semantic Routines project as part of my GSoC 2026 preparation. |
| return true; | ||
| } | ||
|
|
||
| extern (C++) LINK resolvedLinkage(const Declaration d) |
There was a problem hiding this comment.
Put this in cxxfrontend.d (and appropriate C++ header under the correct namespace). The top-level function in dsymbolsem should be extern(D).
There was a problem hiding this comment.
Also link test in compiler/src/tests
There was a problem hiding this comment.
All C++ consumers (gdc and ldc) should access exposed routines via the dmd namespace - for this, dmd::resolvedLinkage(d).
ibuclaw
left a comment
There was a problem hiding this comment.
On a little reflection, Is this is a good example to move? It doesn't do any semantic mutation on the decl. The main reason for splitting out methods from the tree.
|
@ibuclaw thank you for the review, However, would you prefer I to?
Either way, your guidelines regarding cxxfrontend.d are incredibly valuable for mapping out. |
|
Have a look at the cxxfrontend module - what it's doing (its just a simple wrapper around |
|
I think some easy examples to get started would be any of the |
|
thank you @ibuclaw, I will look into how cxxfrontend.d wraps extern(D) symbols using git blame to understand the pattern. |
This PR moves the resolvedLinkage logic from dmd.declaration.Declaration to dmd.dsymbolsem.
As part of the ongoing effort to separate semantic routines from AST nodes, resolvedLinkage was identified as an "intricate" dependency. While it appeared to be a simple property, it performed target-specific resolution (target.systemLinkage()), creating a semantic "leak" in the AST layer.
Changes
Impact
This change decouples the Declaration AST node from the target configuration and allows func.d to move closer to the "Done" list in the "Separate Semantic Routines" migration tracker.