Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some comments in check that required some reverse engineering #4780

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion toolchain/check/check_unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct PackageImports {
: package_id(package_id), node_id(node_id) {}

// The identifier of the imported package.
//
// The current package uses the `IdentifierId::Invalid` id.
Copy link
Contributor

@jonmeow jonmeow Jan 9, 2025

Choose a reason for hiding this comment

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

This semantic isn't specific to CheckUnit. It's in check.cpp, PackagingNames, SemIR::File, etc. I don't think it makes sense to start documenting separately in every place. Maybe it'd be better to find a central way to document this? You could probably add an alias if you prefer (or, PackagingNames is what it all stems from, so it could just be commented there).

Copy link
Contributor

Choose a reason for hiding this comment

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

To be sure, with an alias, I'm thinking something like a documenting IdentifierId::DefaultPackage or something. But we already have LibraryNameId, so another option would be to add a similar PackageIdentifierId type.

IdentifierId package_id;
// The first `import` declaration in the file, which declared the package's
// identifier (even if the import failed). Used for associating diagnostics
Expand Down Expand Up @@ -71,7 +73,8 @@ struct UnitAndImports {
// name lookup.
llvm::SmallVector<PackageImports> package_imports;

// A map of the package names to the outgoing imports above.
// A map of the package names to the outgoing imports above. The
// `IdentifierId::Invalid` id refers to the current package.
Map<IdentifierId, int32_t> package_imports_map;

// The remaining number of imports which must be checked before this unit can
Expand Down
4 changes: 2 additions & 2 deletions toolchain/check/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,8 @@ class Context {
// Maps CheckIRId to ImportIRId.
llvm::SmallVector<SemIR::ImportIRId> check_ir_map_;

// Per-import constant values. These refer to the main IR and mainly serve as
// a lookup table for quick access.
// Per-import constant values, indexed by `SemIR::ImportIRId`. These refer to
// the main IR and mainly serve as a lookup table for quick access.
//
// Inline 0 elements because it's expected to require heap allocation.
llvm::SmallVector<SemIR::ConstantValueStore, 0> import_ir_constant_values_;
Expand Down
Loading