From 0217ec2d3b1e60830a4c9c54d88985f6dd1a6d9d Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Thu, 14 Mar 2024 10:57:09 -0700 Subject: [PATCH] Switch Check's TODO to use SemIRLocation (#3779) Allows dropping a few GetNodeId calls for code cleanliness. --- toolchain/check/context.cpp | 4 ++-- toolchain/check/context.h | 2 +- toolchain/check/eval.cpp | 3 +-- toolchain/check/impl.cpp | 5 ++--- toolchain/check/import_ref.cpp | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/toolchain/check/context.cpp b/toolchain/check/context.cpp index 2d943d3d0d6c..48acab570182 100644 --- a/toolchain/check/context.cpp +++ b/toolchain/check/context.cpp @@ -50,10 +50,10 @@ Context::Context(const Lex::TokenizedBuffer& tokens, DiagnosticEmitter& emitter, SemIR::TypeId::TypeType}); } -auto Context::TODO(Parse::NodeId node_id, std::string label) -> bool { +auto Context::TODO(SemIRLocation loc, std::string label) -> bool { CARBON_DIAGNOSTIC(SemanticsTodo, Error, "Semantics TODO: `{0}`.", std::string); - emitter_->Emit(node_id, SemanticsTodo, std::move(label)); + emitter_->Emit(loc, SemanticsTodo, std::move(label)); return false; } diff --git a/toolchain/check/context.h b/toolchain/check/context.h index deaab5463e3e..8d103a120ea5 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -56,7 +56,7 @@ class Context { SemIR::File& sem_ir, llvm::raw_ostream* vlog_stream); // Marks an implementation TODO. Always returns false. - auto TODO(Parse::NodeId node_id, std::string label) -> bool; + auto TODO(SemIRLocation loc, std::string label) -> bool; // Runs verification that the processing cleanly finished. auto VerifyOnFinish() -> void; diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index 45f315e79e11..f62b8b1dc7ea 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -302,8 +302,7 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) if (!int_bound) { // TODO: Permit symbolic array bounds. This will require fixing // callers of `GetArrayBoundValue`. - context.TODO(context.insts().GetNodeId(bound_id), - "symbolic array bound"); + context.TODO(bound_id, "symbolic array bound"); return false; } // TODO: We should check that the size of the resulting array type diff --git a/toolchain/check/impl.cpp b/toolchain/check/impl.cpp index 0ab6e07f80f4..62e40ad5842f 100644 --- a/toolchain/check/impl.cpp +++ b/toolchain/check/impl.cpp @@ -104,7 +104,7 @@ static auto BuildInterfaceWitness( } } else if (auto const_decl = decl.TryAs()) { // TODO: Check we have a value for this constant in the constraint. - context.TODO(context.insts().GetNodeId(impl.definition_id), + context.TODO(impl.definition_id, "impl of interface with associated constant"); return SemIR::InstId::BuiltinError; } else { @@ -127,8 +127,7 @@ auto BuildImplWitness(Context& context, SemIR::ImplId impl_id) auto interface_type = context.types().TryGetAs(impl.constraint_id); if (!interface_type) { - context.TODO(context.insts().GetNodeId(impl.definition_id), - "impl as non-interface"); + context.TODO(impl.definition_id, "impl as non-interface"); return SemIR::InstId::BuiltinError; } diff --git a/toolchain/check/import_ref.cpp b/toolchain/check/import_ref.cpp index 35254fd540d1..798837223c20 100644 --- a/toolchain/check/import_ref.cpp +++ b/toolchain/check/import_ref.cpp @@ -343,7 +343,7 @@ class ImportRefResolver { default: context_.TODO( - Parse::NodeId::Invalid, + Parse::NodeId(Parse::NodeId::Invalid), llvm::formatv("TryResolveInst on {0}", inst.kind()).str()); return SemIR::ConstantId::Error; }