Skip to content

Add pre semantics plugin hook#5127

Open
ljmf00-wekaio wants to merge 2 commits into
ldc-developers:masterfrom
ljmf00-wekaio:add-pre-semantics-plugin-hook
Open

Add pre semantics plugin hook#5127
ljmf00-wekaio wants to merge 2 commits into
ldc-developers:masterfrom
ljmf00-wekaio:add-pre-semantics-plugin-hook

Conversation

@ljmf00-wekaio
Copy link
Copy Markdown

@ljmf00-wekaio ljmf00-wekaio commented May 11, 2026

Like runSemanticAnalysis, we should have something like runPreSemanticAnalysis. One of the motivations for this is to help referencing AST nodes that represent user code that was deleted by semantics, e.g. constant folding.

CC @JohanEngelen

Signed-off-by: Luis Ferreira <luis.ferreira@weka.io>
…st semantic interfaces

Signed-off-by: Luis Ferreira <luis.ferreira@weka.io>
Comment thread driver/plugins.cpp
for (auto &plugin : sema_plugins) {
assert(plugin.runSemanticAnalysis);
plugin.runSemanticAnalysis(m);
if (plugin.runSemanticAnalysis)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: cleaner to early exit when this is null?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The idea here is to optionally require those functions in the plugin, as now we have multiple of them, but I guess we can keep the old behavior and only make runPreSemanticAnalysis optional.

What if a user only wants to have a plugin for runPreSemanticAnalysis? I can check for both in both places (if they have at least one).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's not what i meant. I agree with the change that both are optional.

I just meant hoisting the if-statement out of the loop :)

@JohanEngelen
Copy link
Copy Markdown
Member

It's a good addition I think, although it is a workaround around a fundamental frontend issue (information loss after sema).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants