context.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_CHECK_CONTEXT_H_
  5. #define CARBON_TOOLCHAIN_CHECK_CONTEXT_H_
  6. #include "llvm/ADT/DenseMap.h"
  7. #include "llvm/ADT/FoldingSet.h"
  8. #include "llvm/ADT/SmallVector.h"
  9. #include "toolchain/check/decl_introducer_state.h"
  10. #include "toolchain/check/decl_name_stack.h"
  11. #include "toolchain/check/diagnostic_helpers.h"
  12. #include "toolchain/check/inst_block_stack.h"
  13. #include "toolchain/check/node_stack.h"
  14. #include "toolchain/check/param_and_arg_refs_stack.h"
  15. #include "toolchain/check/scope_stack.h"
  16. #include "toolchain/parse/node_ids.h"
  17. #include "toolchain/parse/tree.h"
  18. #include "toolchain/sem_ir/file.h"
  19. #include "toolchain/sem_ir/ids.h"
  20. #include "toolchain/sem_ir/import_ir.h"
  21. #include "toolchain/sem_ir/inst.h"
  22. namespace Carbon::Check {
  23. // Context and shared functionality for semantics handlers.
  24. class Context {
  25. public:
  26. using DiagnosticEmitter = Carbon::DiagnosticEmitter<SemIRLoc>;
  27. using DiagnosticBuilder = DiagnosticEmitter::DiagnosticBuilder;
  28. // Stores references for work.
  29. explicit Context(const Lex::TokenizedBuffer& tokens,
  30. DiagnosticEmitter& emitter, const Parse::Tree& parse_tree,
  31. SemIR::File& sem_ir, llvm::raw_ostream* vlog_stream);
  32. // Marks an implementation TODO. Always returns false.
  33. auto TODO(SemIRLoc loc, std::string label) -> bool;
  34. // Runs verification that the processing cleanly finished.
  35. auto VerifyOnFinish() -> void;
  36. // Adds an instruction to the current block, returning the produced ID.
  37. auto AddInst(SemIR::LocIdAndInst loc_id_and_inst) -> SemIR::InstId;
  38. // Convenience for AddInst on specific instruction types.
  39. template <typename InstT, typename LocT>
  40. auto AddInst(LocT loc_id, InstT inst) -> SemIR::InstId {
  41. return AddInst(SemIR::LocIdAndInst(loc_id, inst));
  42. }
  43. // Adds an instruction in no block, returning the produced ID. Should be used
  44. // rarely.
  45. auto AddInstInNoBlock(SemIR::LocIdAndInst loc_id_and_inst) -> SemIR::InstId;
  46. // Convenience for AddInstInNoBlock on specific instruction types.
  47. template <typename InstT, typename LocT>
  48. auto AddInstInNoBlock(LocT loc_id, InstT inst) -> SemIR::InstId {
  49. return AddInstInNoBlock(SemIR::LocIdAndInst(loc_id, inst));
  50. }
  51. // Adds an instruction to the current block, returning the produced ID. The
  52. // instruction is a placeholder that is expected to be replaced by
  53. // `ReplaceInstBeforeConstantUse`.
  54. auto AddPlaceholderInst(SemIR::LocIdAndInst loc_id_and_inst) -> SemIR::InstId;
  55. // Adds an instruction in no block, returning the produced ID. Should be used
  56. // rarely. The instruction is a placeholder that is expected to be replaced by
  57. // `ReplaceInstBeforeConstantUse`.
  58. auto AddPlaceholderInstInNoBlock(SemIR::LocIdAndInst loc_id_and_inst)
  59. -> SemIR::InstId;
  60. // Adds an instruction to the constants block, returning the produced ID.
  61. auto AddConstant(SemIR::Inst inst, bool is_symbolic) -> SemIR::ConstantId;
  62. // Pushes a parse tree node onto the stack, storing the SemIR::Inst as the
  63. // result. Only valid if the LocId is for a NodeId.
  64. template <typename InstT, typename LocT>
  65. auto AddInstAndPush(LocT loc_id, InstT inst) -> void {
  66. SemIR::LocIdAndInst arg(loc_id, inst);
  67. auto inst_id = AddInst(arg);
  68. node_stack_.Push(arg.loc_id.node_id(), inst_id);
  69. }
  70. // Replaces the instruction `inst_id` with `loc_id_and_inst`. The instruction
  71. // is required to not have been used in any constant evaluation, either
  72. // because it's newly created and entirely unused, or because it's only used
  73. // in a position that constant evaluation ignores, such as a return slot.
  74. auto ReplaceLocIdAndInstBeforeConstantUse(SemIR::InstId inst_id,
  75. SemIR::LocIdAndInst loc_id_and_inst)
  76. -> void;
  77. // Replaces the instruction `inst_id` with `inst`, not affecting location.
  78. // The instruction is required to not have been used in any constant
  79. // evaluation, either because it's newly created and entirely unused, or
  80. // because it's only used in a position that constant evaluation ignores, such
  81. // as a return slot.
  82. auto ReplaceInstBeforeConstantUse(SemIR::InstId inst_id, SemIR::Inst inst)
  83. -> void;
  84. // Sets only the parse node of an instruction. This is only used when setting
  85. // the parse node of an imported namespace. Versus
  86. // ReplaceInstBeforeConstantUse, it is safe to use after the namespace is used
  87. // in constant evaluation. It's exposed this way mainly so that `insts()` can
  88. // remain const.
  89. auto SetNamespaceNodeId(SemIR::InstId inst_id, Parse::NodeId node_id)
  90. -> void {
  91. sem_ir().insts().SetLocId(inst_id, SemIR::LocId(node_id));
  92. }
  93. // Adds a name to name lookup. Prints a diagnostic for name conflicts.
  94. auto AddNameToLookup(SemIR::NameId name_id, SemIR::InstId target_id) -> void;
  95. // Performs name lookup in a specified scope for a name appearing in a
  96. // declaration, returning the referenced instruction. If scope_id is invalid,
  97. // uses the current contextual scope.
  98. auto LookupNameInDecl(SemIR::LocId loc_id, SemIR::NameId name_id,
  99. SemIR::NameScopeId scope_id) -> SemIR::InstId;
  100. // Performs an unqualified name lookup, returning the referenced instruction.
  101. auto LookupUnqualifiedName(Parse::NodeId node_id, SemIR::NameId name_id)
  102. -> SemIR::InstId;
  103. // Performs a name lookup in a specified scope, returning the referenced
  104. // instruction. Does not look into extended scopes. Returns an invalid
  105. // instruction if the name is not found.
  106. auto LookupNameInExactScope(SemIRLoc loc, SemIR::NameId name_id,
  107. SemIR::NameScopeId scope_id,
  108. const SemIR::NameScope& scope) -> SemIR::InstId;
  109. // Performs a qualified name lookup in a specified scope and in scopes that
  110. // it extends, returning the referenced instruction.
  111. auto LookupQualifiedName(Parse::NodeId node_id, SemIR::NameId name_id,
  112. SemIR::NameScopeId scope_id, bool required = true)
  113. -> SemIR::InstId;
  114. // Returns the instruction corresponding to a name in the core package, or
  115. // BuiltinError if not found.
  116. auto LookupNameInCore(SemIRLoc loc, llvm::StringRef name) -> SemIR::InstId;
  117. // Prints a diagnostic for a duplicate name.
  118. auto DiagnoseDuplicateName(SemIRLoc dup_def, SemIRLoc prev_def) -> void;
  119. // Prints a diagnostic for a missing name.
  120. auto DiagnoseNameNotFound(SemIRLoc loc, SemIR::NameId name_id) -> void;
  121. // Adds a note to a diagnostic explaining that a class is incomplete.
  122. auto NoteIncompleteClass(SemIR::ClassId class_id, DiagnosticBuilder& builder)
  123. -> void;
  124. // Adds a note to a diagnostic explaining that an interface is not defined.
  125. auto NoteUndefinedInterface(SemIR::InterfaceId interface_id,
  126. DiagnosticBuilder& builder) -> void;
  127. // Returns the current scope, if it is of the specified kind. Otherwise,
  128. // returns nullopt.
  129. template <typename InstT>
  130. auto GetCurrentScopeAs() -> std::optional<InstT> {
  131. return scope_stack().GetCurrentScopeAs<InstT>(sem_ir());
  132. }
  133. // Adds a `Branch` instruction branching to a new instruction block, and
  134. // returns the ID of the new block. All paths to the branch target must go
  135. // through the current block, though not necessarily through this branch.
  136. auto AddDominatedBlockAndBranch(Parse::NodeId node_id) -> SemIR::InstBlockId;
  137. // Adds a `Branch` instruction branching to a new instruction block with a
  138. // value, and returns the ID of the new block. All paths to the branch target
  139. // must go through the current block.
  140. auto AddDominatedBlockAndBranchWithArg(Parse::NodeId node_id,
  141. SemIR::InstId arg_id)
  142. -> SemIR::InstBlockId;
  143. // Adds a `BranchIf` instruction branching to a new instruction block, and
  144. // returns the ID of the new block. All paths to the branch target must go
  145. // through the current block.
  146. auto AddDominatedBlockAndBranchIf(Parse::NodeId node_id,
  147. SemIR::InstId cond_id)
  148. -> SemIR::InstBlockId;
  149. // Handles recovergence of control flow. Adds branches from the top
  150. // `num_blocks` on the instruction block stack to a new block, pops the
  151. // existing blocks, and pushes the new block onto the instruction block stack.
  152. auto AddConvergenceBlockAndPush(Parse::NodeId node_id, int num_blocks)
  153. -> void;
  154. // Handles recovergence of control flow with a result value. Adds branches
  155. // from the top few blocks on the instruction block stack to a new block, pops
  156. // the existing blocks, and pushes the new block onto the instruction block
  157. // stack. The number of blocks popped is the size of `block_args`, and the
  158. // corresponding result values are the elements of `block_args`. Returns an
  159. // instruction referring to the result value.
  160. auto AddConvergenceBlockWithArgAndPush(
  161. Parse::NodeId node_id, std::initializer_list<SemIR::InstId> block_args)
  162. -> SemIR::InstId;
  163. // Sets the constant value of a block argument created as the result of a
  164. // branch. `select_id` should be a `BlockArg` that selects between two
  165. // values. `cond_id` is the condition, `if_false` is the value to use if the
  166. // condition is false, and `if_true` is the value to use if the condition is
  167. // true. We don't track enough information in the `BlockArg` inst for
  168. // `TryEvalInst` to do this itself.
  169. auto SetBlockArgResultBeforeConstantUse(SemIR::InstId select_id,
  170. SemIR::InstId cond_id,
  171. SemIR::InstId if_true,
  172. SemIR::InstId if_false) -> void;
  173. // Add the current code block to the enclosing function.
  174. // TODO: The node_id is taken for expressions, which can occur in
  175. // non-function contexts. This should be refactored to support non-function
  176. // contexts, and node_id removed.
  177. auto AddCurrentCodeBlockToFunction(
  178. Parse::NodeId node_id = Parse::NodeId::Invalid) -> void;
  179. // Returns whether the current position in the current block is reachable.
  180. auto is_current_position_reachable() -> bool;
  181. // Returns the type ID for a constant of type `type`.
  182. auto GetTypeIdForTypeConstant(SemIR::ConstantId constant_id) -> SemIR::TypeId;
  183. // Returns the type ID for an instruction whose constant value is of type
  184. // `type`.
  185. auto GetTypeIdForTypeInst(SemIR::InstId inst_id) -> SemIR::TypeId {
  186. return GetTypeIdForTypeConstant(constant_values().Get(inst_id));
  187. }
  188. // Attempts to complete the type `type_id`. Returns `true` if the type is
  189. // complete, or `false` if it could not be completed. A complete type has
  190. // known object and value representations.
  191. //
  192. // If the type is not complete, `diagnoser` is invoked to diagnose the issue,
  193. // if a `diagnoser` is provided. The builder it returns will be annotated to
  194. // describe the reason why the type is not complete.
  195. auto TryToCompleteType(
  196. SemIR::TypeId type_id,
  197. std::optional<llvm::function_ref<auto()->DiagnosticBuilder>> diagnoser =
  198. std::nullopt) -> bool;
  199. // Returns the type `type_id` as a complete type, or produces an incomplete
  200. // type error and returns an error type. This is a convenience wrapper around
  201. // TryToCompleteType.
  202. auto AsCompleteType(SemIR::TypeId type_id,
  203. llvm::function_ref<auto()->DiagnosticBuilder> diagnoser)
  204. -> SemIR::TypeId {
  205. return TryToCompleteType(type_id, diagnoser) ? type_id
  206. : SemIR::TypeId::Error;
  207. }
  208. // TODO: Consider moving these `Get*Type` functions to a separate class.
  209. // Gets the type for the name of an associated entity.
  210. auto GetAssociatedEntityType(SemIR::InterfaceId interface_id,
  211. SemIR::TypeId entity_type_id) -> SemIR::TypeId;
  212. // Gets a builtin type. The returned type will be complete.
  213. auto GetBuiltinType(SemIR::BuiltinKind kind) -> SemIR::TypeId;
  214. // Gets a function type. The returned type will be complete.
  215. auto GetFunctionType(SemIR::FunctionId fn_id) -> SemIR::TypeId;
  216. // Gets a generic class type, which is the type of a name of a generic class,
  217. // such as the type of `Vector` given `class Vector(T:! type)`. The returned
  218. // type will be complete.
  219. auto GetGenericClassType(SemIR::ClassId class_id) -> SemIR::TypeId;
  220. // Gets a generic interface type, which is the type of a name of a generic
  221. // interface, such as the type of `AddWith` given
  222. // `interface AddWith(T:! type)`. The returned type will be complete.
  223. auto GetGenericInterfaceType(SemIR::InterfaceId interface_id)
  224. -> SemIR::TypeId;
  225. // Returns a pointer type whose pointee type is `pointee_type_id`.
  226. auto GetPointerType(SemIR::TypeId pointee_type_id) -> SemIR::TypeId;
  227. // Returns a struct type with the given fields, which should be a block of
  228. // `StructTypeField`s.
  229. auto GetStructType(SemIR::InstBlockId refs_id) -> SemIR::TypeId;
  230. // Returns a tuple type with the given element types.
  231. auto GetTupleType(llvm::ArrayRef<SemIR::TypeId> type_ids) -> SemIR::TypeId;
  232. // Returns an unbound element type.
  233. auto GetUnboundElementType(SemIR::TypeId class_type_id,
  234. SemIR::TypeId element_type_id) -> SemIR::TypeId;
  235. // Removes any top-level `const` qualifiers from a type.
  236. auto GetUnqualifiedType(SemIR::TypeId type_id) -> SemIR::TypeId;
  237. // Adds an exported name.
  238. auto AddExport(SemIR::InstId inst_id) -> void { exports_.push_back(inst_id); }
  239. // Finalizes the list of exports on the IR.
  240. auto FinalizeExports() -> void {
  241. inst_blocks().Set(SemIR::InstBlockId::Exports, exports_);
  242. }
  243. // Finalizes the initialization function (__global_init).
  244. auto FinalizeGlobalInit() -> void;
  245. // Sets the total number of IRs which exist. This is used to prepare a map
  246. // from IR to imported IR.
  247. auto SetTotalIRCount(int num_irs) -> void {
  248. CARBON_CHECK(check_ir_map_.empty())
  249. << "SetTotalIRCount is only called once";
  250. check_ir_map_.resize(num_irs, SemIR::ImportIRId::Invalid);
  251. }
  252. // Returns the imported IR ID for an IR, or invalid if not imported.
  253. auto GetImportIRId(const SemIR::File& sem_ir) -> SemIR::ImportIRId& {
  254. return check_ir_map_[sem_ir.check_ir_id().index];
  255. }
  256. // True if the current file is an impl file.
  257. auto IsImplFile() -> bool {
  258. return sem_ir_->import_irs().Get(SemIR::ImportIRId::ApiForImpl).sem_ir !=
  259. nullptr;
  260. }
  261. // Prints information for a stack dump.
  262. auto PrintForStackDump(llvm::raw_ostream& output) const -> void;
  263. // Get the Lex::TokenKind of a node for diagnostics.
  264. auto token_kind(Parse::NodeId node_id) -> Lex::TokenKind {
  265. return tokens().GetKind(parse_tree().node_token(node_id));
  266. }
  267. auto tokens() -> const Lex::TokenizedBuffer& { return *tokens_; }
  268. auto emitter() -> DiagnosticEmitter& { return *emitter_; }
  269. auto parse_tree() -> const Parse::Tree& { return *parse_tree_; }
  270. auto sem_ir() -> SemIR::File& { return *sem_ir_; }
  271. auto node_stack() -> NodeStack& { return node_stack_; }
  272. auto inst_block_stack() -> InstBlockStack& { return inst_block_stack_; }
  273. auto param_and_arg_refs_stack() -> ParamAndArgRefsStack& {
  274. return param_and_arg_refs_stack_;
  275. }
  276. auto args_type_info_stack() -> InstBlockStack& {
  277. return args_type_info_stack_;
  278. }
  279. auto decl_name_stack() -> DeclNameStack& { return decl_name_stack_; }
  280. auto decl_introducer_state_stack() -> DeclIntroducerStateStack& {
  281. return decl_introducer_state_stack_;
  282. }
  283. auto scope_stack() -> ScopeStack& { return scope_stack_; }
  284. auto return_scope_stack() -> llvm::SmallVector<ScopeStack::ReturnScope>& {
  285. return scope_stack().return_scope_stack();
  286. }
  287. auto break_continue_stack()
  288. -> llvm::SmallVector<ScopeStack::BreakContinueScope>& {
  289. return scope_stack().break_continue_stack();
  290. }
  291. auto import_ir_constant_values()
  292. -> llvm::SmallVector<SemIR::ConstantValueStore, 0>& {
  293. return import_ir_constant_values_;
  294. }
  295. // Directly expose SemIR::File data accessors for brevity in calls.
  296. auto identifiers() -> StringStoreWrapper<IdentifierId>& {
  297. return sem_ir().identifiers();
  298. }
  299. auto ints() -> CanonicalValueStore<IntId>& { return sem_ir().ints(); }
  300. auto reals() -> ValueStore<RealId>& { return sem_ir().reals(); }
  301. auto floats() -> FloatValueStore& { return sem_ir().floats(); }
  302. auto string_literal_values() -> StringStoreWrapper<StringLiteralValueId>& {
  303. return sem_ir().string_literal_values();
  304. }
  305. auto bind_names() -> SemIR::BindNameStore& { return sem_ir().bind_names(); }
  306. auto functions() -> ValueStore<SemIR::FunctionId>& {
  307. return sem_ir().functions();
  308. }
  309. auto classes() -> ValueStore<SemIR::ClassId>& { return sem_ir().classes(); }
  310. auto interfaces() -> ValueStore<SemIR::InterfaceId>& {
  311. return sem_ir().interfaces();
  312. }
  313. auto impls() -> SemIR::ImplStore& { return sem_ir().impls(); }
  314. auto generics() -> ValueStore<SemIR::GenericId>& {
  315. return sem_ir().generics();
  316. }
  317. auto generic_instances() -> SemIR::GenericInstanceStore& {
  318. return sem_ir().generic_instances();
  319. }
  320. auto import_irs() -> ValueStore<SemIR::ImportIRId>& {
  321. return sem_ir().import_irs();
  322. }
  323. auto import_ir_insts() -> ValueStore<SemIR::ImportIRInstId>& {
  324. return sem_ir().import_ir_insts();
  325. }
  326. auto names() -> SemIR::NameStoreWrapper { return sem_ir().names(); }
  327. auto name_scopes() -> SemIR::NameScopeStore& {
  328. return sem_ir().name_scopes();
  329. }
  330. auto types() -> SemIR::TypeStore& { return sem_ir().types(); }
  331. auto type_blocks() -> SemIR::BlockValueStore<SemIR::TypeBlockId>& {
  332. return sem_ir().type_blocks();
  333. }
  334. // Instructions should be added with `AddInst` or `AddInstInNoBlock`. This is
  335. // `const` to prevent accidental misuse.
  336. auto insts() -> const SemIR::InstStore& { return sem_ir().insts(); }
  337. auto constant_values() -> SemIR::ConstantValueStore& {
  338. return sem_ir().constant_values();
  339. }
  340. auto inst_blocks() -> SemIR::InstBlockStore& {
  341. return sem_ir().inst_blocks();
  342. }
  343. auto constants() -> SemIR::ConstantStore& { return sem_ir().constants(); }
  344. auto definitions_required() -> llvm::SmallVector<SemIR::InstId>& {
  345. return definitions_required_;
  346. }
  347. private:
  348. // A FoldingSet node for a type.
  349. class TypeNode : public llvm::FastFoldingSetNode {
  350. public:
  351. explicit TypeNode(const llvm::FoldingSetNodeID& node_id,
  352. SemIR::TypeId type_id)
  353. : llvm::FastFoldingSetNode(node_id), type_id_(type_id) {}
  354. auto type_id() -> SemIR::TypeId { return type_id_; }
  355. private:
  356. SemIR::TypeId type_id_;
  357. };
  358. // Tokens for getting data on literals.
  359. const Lex::TokenizedBuffer* tokens_;
  360. // Handles diagnostics.
  361. DiagnosticEmitter* emitter_;
  362. // The file's parse tree.
  363. const Parse::Tree* parse_tree_;
  364. // The SemIR::File being added to.
  365. SemIR::File* sem_ir_;
  366. // Whether to print verbose output.
  367. llvm::raw_ostream* vlog_stream_;
  368. // The stack during Build. Will contain file-level parse nodes on return.
  369. NodeStack node_stack_;
  370. // The stack of instruction blocks being used for general IR generation.
  371. InstBlockStack inst_block_stack_;
  372. // The stack of instruction blocks being used for param and arg ref blocks.
  373. ParamAndArgRefsStack param_and_arg_refs_stack_;
  374. // The stack of instruction blocks being used for type information while
  375. // processing arguments. This is used in parallel with
  376. // param_and_arg_refs_stack_. It's currently only used for struct literals,
  377. // where we need to track names for a type separate from the literal
  378. // arguments.
  379. InstBlockStack args_type_info_stack_;
  380. // The stack used for qualified declaration name construction.
  381. DeclNameStack decl_name_stack_;
  382. // The stack of declarations that could have modifiers.
  383. DeclIntroducerStateStack decl_introducer_state_stack_;
  384. // The stack of scopes we are currently within.
  385. ScopeStack scope_stack_;
  386. // Cache of reverse mapping from type constants to types.
  387. //
  388. // TODO: Instead of mapping to a dense `TypeId` space, we could make `TypeId`
  389. // be a thin wrapper around `ConstantId` and only perform the lookup only when
  390. // we want to access the completeness and value representation of a type. It's
  391. // not clear whether that would result in more or fewer lookups.
  392. //
  393. // TODO: Should this be part of the `TypeStore`?
  394. llvm::DenseMap<SemIR::ConstantId, SemIR::TypeId> type_ids_for_type_constants_;
  395. // The list which will form NodeBlockId::Exports.
  396. llvm::SmallVector<SemIR::InstId> exports_;
  397. // Maps CheckIRId to ImportIRId.
  398. llvm::SmallVector<SemIR::ImportIRId> check_ir_map_;
  399. // Per-import constant values. These refer to the main IR and mainly serve as
  400. // a lookup table for quick access.
  401. //
  402. // Inline 0 elements because it's expected to require heap allocation.
  403. llvm::SmallVector<SemIR::ConstantValueStore, 0> import_ir_constant_values_;
  404. // Declaration instructions of entities that should have definitions by the
  405. // end of the current source file.
  406. llvm::SmallVector<SemIR::InstId> definitions_required_;
  407. };
  408. } // namespace Carbon::Check
  409. #endif // CARBON_TOOLCHAIN_CHECK_CONTEXT_H_