Support ref tags on arguments to ref params (#6312)

The issue of whether/how to include `ref` tags in the textual and
in-memory SemIR (see discussion
[here](https://discord.com/channels/655572317891461132/655578254970716160/1431316355742961805))
is left as future work.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Geoff Romer
2025-11-11 20:30:19 +00:00
committed by GitHub
co-authored by Richard Smith
parent b36f85c2a5
commit 43ffd721a4
39 changed files with 798 additions and 337 deletions
+14
View File
@@ -8,6 +8,7 @@
#include <utility>
#include "common/check.h"
#include "toolchain/base/kind_switch.h"
#include "toolchain/check/deferred_definition_worklist.h"
#include "toolchain/sem_ir/ids.h"
@@ -77,6 +78,19 @@ auto Context::VerifyOnFinish() const -> void {
CARBON_FATAL("{0}Built invalid semantics IR: {1}\n", sem_ir_,
verify.error());
}
if (!sem_ir_->has_errors()) {
auto ref_tags_needed = sem_ir_->CollectRefTagsNeeded();
ref_tags_.ForEach([&ref_tags_needed](SemIR::InstId inst_id, RefTag kind) {
CARBON_CHECK(
ref_tags_needed.Erase(inst_id) || kind == RefTag::NotRequired,
"Inst has unnecessary `ref` tag: {0}", inst_id);
});
ref_tags_needed.ForEach([this](SemIR::InstId inst_id) {
CARBON_FATAL("Inst missing `ref` tag: {0}", insts().Get(inst_id));
});
}
#endif
}