generic.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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. #include "toolchain/check/generic.h"
  5. #include "common/map.h"
  6. #include "toolchain/base/kind_switch.h"
  7. #include "toolchain/check/eval.h"
  8. #include "toolchain/check/generic_region_stack.h"
  9. #include "toolchain/check/subst.h"
  10. #include "toolchain/check/type.h"
  11. #include "toolchain/check/type_completion.h"
  12. #include "toolchain/sem_ir/generic.h"
  13. #include "toolchain/sem_ir/ids.h"
  14. #include "toolchain/sem_ir/inst.h"
  15. #include "toolchain/sem_ir/typed_insts.h"
  16. namespace Carbon::Check {
  17. static auto MakeSelfSpecificId(Context& context, SemIR::GenericId generic_id)
  18. -> SemIR::SpecificId;
  19. static auto ResolveSpecificDeclaration(Context& context, SemIRLoc loc,
  20. SemIR::SpecificId specific_id) -> void;
  21. auto StartGenericDecl(Context& context) -> void {
  22. context.generic_region_stack().Push();
  23. }
  24. auto StartGenericDefinition(Context& context) -> void {
  25. // Push a generic region even if we don't have a generic_id. We might still
  26. // have locally-introduced generic parameters to track:
  27. //
  28. // fn F() {
  29. // let T:! type = i32;
  30. // var x: T;
  31. // }
  32. context.generic_region_stack().Push();
  33. }
  34. // Adds an instruction `generic_inst_id` to the eval block for a generic region,
  35. // which is the current instruction block. The instruction `generic_inst_id` is
  36. // expected to compute the value of the constant described by `const_inst_id` in
  37. // each specific. Forms and returns a corresponding symbolic constant ID that
  38. // refers to the substituted value of that instruction in each specific.
  39. static auto AddGenericConstantInstToEvalBlock(
  40. Context& context, SemIR::GenericId generic_id,
  41. SemIR::GenericInstIndex::Region region, SemIR::InstId const_inst_id,
  42. SemIR::InstId generic_inst_id) -> SemIR::ConstantId {
  43. auto index = SemIR::GenericInstIndex(
  44. region, context.inst_block_stack().PeekCurrentBlockContents().size());
  45. context.inst_block_stack().AddInstId(generic_inst_id);
  46. return context.constant_values().AddSymbolicConstant(
  47. {.inst_id = const_inst_id, .generic_id = generic_id, .index = index});
  48. }
  49. namespace {
  50. // A map from an instruction ID representing a canonical symbolic constant to an
  51. // instruction within an eval block of the generic that computes the specific
  52. // value for that constant.
  53. //
  54. // We arbitrarily use a small size of 256 bytes for the map.
  55. // TODO: Determine a better number based on measurements.
  56. using ConstantsInGenericMap = Map<SemIR::InstId, SemIR::InstId, 256>;
  57. // Substitution callbacks to rebuild a generic constant in the eval block for a
  58. // generic region.
  59. class RebuildGenericConstantInEvalBlockCallbacks final
  60. : public SubstInstCallbacks {
  61. public:
  62. RebuildGenericConstantInEvalBlockCallbacks(
  63. Context& context, SemIR::GenericId generic_id,
  64. SemIR::GenericInstIndex::Region region, SemIR::LocId loc_id,
  65. ConstantsInGenericMap& constants_in_generic)
  66. : context_(context),
  67. generic_id_(generic_id),
  68. region_(region),
  69. loc_id_(loc_id),
  70. constants_in_generic_(constants_in_generic) {}
  71. // Check for instructions for which we already have a mapping into the eval
  72. // block, and substitute them for the instructions in the eval block.
  73. auto Subst(SemIR::InstId& inst_id) const -> bool override {
  74. auto const_id = context_.constant_values().Get(inst_id);
  75. if (!const_id.has_value()) {
  76. // An unloaded import ref should never contain anything we need to
  77. // substitute into. Don't trigger loading it here.
  78. CARBON_CHECK(
  79. context_.insts().Is<SemIR::ImportRefUnloaded>(inst_id),
  80. "Substituting into instruction with invalid constant ID: {0}",
  81. context_.insts().Get(inst_id));
  82. return true;
  83. }
  84. if (!context_.constant_values().DependsOnGenericParameter(const_id)) {
  85. // This instruction doesn't have a symbolic constant value, so can't
  86. // contain any bindings that need to be substituted.
  87. return true;
  88. }
  89. // If this instruction is in the map, return the known result.
  90. if (auto result = constants_in_generic_.Lookup(
  91. context_.constant_values().GetInstId(const_id))) {
  92. // In order to reuse instructions from the generic as often as possible,
  93. // keep this instruction as-is if it already has the desired symbolic
  94. // constant value.
  95. if (const_id != context_.constant_values().Get(result.value())) {
  96. inst_id = result.value();
  97. }
  98. CARBON_CHECK(inst_id.has_value());
  99. return true;
  100. }
  101. // If the instruction is a symbolic binding, build a version in the eval
  102. // block.
  103. if (auto binding =
  104. context_.insts().TryGetAs<SemIR::BindSymbolicName>(inst_id)) {
  105. if (context_.entity_names()
  106. .Get(binding->entity_name_id)
  107. .bind_index()
  108. .has_value()) {
  109. inst_id = Rebuild(inst_id, *binding);
  110. return true;
  111. }
  112. }
  113. if (auto pattern =
  114. context_.insts().TryGetAs<SemIR::SymbolicBindingPattern>(inst_id)) {
  115. inst_id = Rebuild(inst_id, *pattern);
  116. return true;
  117. }
  118. return false;
  119. }
  120. // Build a new instruction in the eval block corresponding to the given
  121. // constant.
  122. auto Rebuild(SemIR::InstId orig_inst_id, SemIR::Inst new_inst) const
  123. -> SemIR::InstId override {
  124. auto const_inst_id =
  125. context_.constant_values().GetConstantInstId(orig_inst_id);
  126. // We might already have an instruction in the eval block if a transitive
  127. // operand of this instruction has the same constant value.
  128. auto result = constants_in_generic_.Insert(const_inst_id, [&] {
  129. // TODO: Add a function on `Context` to add the instruction without
  130. // inserting it into the dependent instructions list or computing a
  131. // constant value for it.
  132. // TODO: Is the location we pick here always appropriate for the new
  133. // instruction?
  134. auto inst_id = context_.sem_ir().insts().AddInNoBlock(
  135. SemIR::LocIdAndInst::UncheckedLoc(loc_id_, new_inst));
  136. auto const_id = AddGenericConstantInstToEvalBlock(
  137. context_, generic_id_, region_, const_inst_id, inst_id);
  138. context_.constant_values().Set(inst_id, const_id);
  139. return inst_id;
  140. });
  141. return result.value();
  142. }
  143. private:
  144. Context& context_;
  145. SemIR::GenericId generic_id_;
  146. SemIR::GenericInstIndex::Region region_;
  147. SemIR::LocId loc_id_;
  148. ConstantsInGenericMap& constants_in_generic_;
  149. };
  150. } // namespace
  151. // Adds instructions to compute the substituted version of `type_id` in each
  152. // specific into the eval block for the generic, which is the current
  153. // instruction block. Returns a symbolic type ID that refers to the substituted
  154. // type in each specific.
  155. static auto AddGenericTypeToEvalBlock(
  156. Context& context, SemIR::GenericId generic_id,
  157. SemIR::GenericInstIndex::Region region, SemIR::LocId loc_id,
  158. ConstantsInGenericMap& constants_in_generic, SemIR::TypeId type_id)
  159. -> SemIR::TypeId {
  160. // Substitute into the type's constant instruction and rebuild it in the eval
  161. // block.
  162. auto type_inst_id =
  163. SubstInst(context, context.types().GetInstId(type_id),
  164. RebuildGenericConstantInEvalBlockCallbacks(
  165. context, generic_id, region, loc_id, constants_in_generic));
  166. return context.types().GetTypeIdForTypeInstId(type_inst_id);
  167. }
  168. // Adds instructions to compute the substituted value of `inst_id` in each
  169. // specific into the eval block for the generic, which is the current
  170. // instruction block. Returns a symbolic constant instruction ID that refers to
  171. // the substituted constant value in each specific.
  172. static auto AddGenericConstantToEvalBlock(
  173. Context& context, SemIR::GenericId generic_id,
  174. SemIR::GenericInstIndex::Region region,
  175. ConstantsInGenericMap& constants_in_generic, SemIR::InstId inst_id)
  176. -> SemIR::ConstantId {
  177. // Substitute into the constant value and rebuild it in the eval block if
  178. // we've not encountered it before.
  179. auto const_inst_id = context.constant_values().GetConstantInstId(inst_id);
  180. auto new_inst_id =
  181. SubstInst(context, const_inst_id,
  182. RebuildGenericConstantInEvalBlockCallbacks(
  183. context, generic_id, region,
  184. context.insts().GetLocId(inst_id), constants_in_generic));
  185. CARBON_CHECK(new_inst_id != const_inst_id,
  186. "Did not apply any substitutions to symbolic constant {0}",
  187. context.insts().Get(const_inst_id));
  188. return context.constant_values().Get(new_inst_id);
  189. }
  190. // Populates a map of constants in a generic from the constants in the
  191. // declaration region, in preparation for building the definition region.
  192. static auto PopulateConstantsFromDeclaration(
  193. Context& context, SemIR::GenericId generic_id,
  194. ConstantsInGenericMap& constants_in_generic) {
  195. // For the definition region, populate constants from the declaration.
  196. auto decl_eval_block = context.inst_blocks().Get(
  197. context.generics().Get(generic_id).decl_block_id);
  198. constants_in_generic.GrowForInsertCount(decl_eval_block.size());
  199. for (auto inst_id : decl_eval_block) {
  200. auto const_inst_id = context.constant_values().GetConstantInstId(inst_id);
  201. auto result = constants_in_generic.Insert(const_inst_id, inst_id);
  202. CARBON_CHECK(result.is_inserted(),
  203. "Duplicate constant in generic decl eval block: {0}",
  204. context.insts().Get(const_inst_id));
  205. }
  206. }
  207. // Builds and returns a block of instructions whose constant values need to be
  208. // evaluated in order to resolve a generic to a specific.
  209. static auto MakeGenericEvalBlock(Context& context, SemIR::GenericId generic_id,
  210. SemIR::GenericInstIndex::Region region)
  211. -> SemIR::InstBlockId {
  212. context.inst_block_stack().Push();
  213. ConstantsInGenericMap constants_in_generic;
  214. // For the definition region, populate constants from the declaration.
  215. if (region == SemIR::GenericInstIndex::Region::Definition) {
  216. PopulateConstantsFromDeclaration(context, generic_id, constants_in_generic);
  217. }
  218. // The work done in this loop might invalidate iterators into the generic
  219. // region stack, but shouldn't add new dependent instructions to the current
  220. // region.
  221. auto num_dependent_insts =
  222. context.generic_region_stack().PeekDependentInsts().size();
  223. for (auto i : llvm::seq(num_dependent_insts)) {
  224. auto [inst_id, dep_kind] =
  225. context.generic_region_stack().PeekDependentInsts()[i];
  226. // If the type is symbolic, replace it with a type specific to this generic.
  227. if ((dep_kind & GenericRegionStack::DependencyKind::SymbolicType) !=
  228. GenericRegionStack::DependencyKind::None) {
  229. auto inst = context.insts().Get(inst_id);
  230. auto type_id = AddGenericTypeToEvalBlock(
  231. context, generic_id, region, context.insts().GetLocId(inst_id),
  232. constants_in_generic, inst.type_id());
  233. // TODO: Eventually, completeness requirements should be modeled as
  234. // constraints on the generic rather than properties of the type. For now,
  235. // require the transformed type to be complete if the original was.
  236. if (context.types().IsComplete(inst.type_id())) {
  237. CompleteTypeOrCheckFail(context, type_id);
  238. }
  239. inst.SetType(type_id);
  240. context.sem_ir().insts().Set(inst_id, inst);
  241. }
  242. // If the instruction has a symbolic constant value, then make a note that
  243. // we'll need to evaluate this instruction when forming the specific. Update
  244. // the constant value of the instruction to refer to the result of that
  245. // eventual evaluation.
  246. if ((dep_kind & GenericRegionStack::DependencyKind::SymbolicConstant) !=
  247. GenericRegionStack::DependencyKind::None) {
  248. // Update the constant value to refer to this generic.
  249. context.constant_values().Set(
  250. inst_id,
  251. AddGenericConstantToEvalBlock(context, generic_id, region,
  252. constants_in_generic, inst_id));
  253. }
  254. }
  255. CARBON_CHECK(
  256. num_dependent_insts ==
  257. context.generic_region_stack().PeekDependentInsts().size(),
  258. "Building eval block added new dependent insts, for example {0}",
  259. context.insts().Get(context.generic_region_stack()
  260. .PeekDependentInsts()[num_dependent_insts]
  261. .inst_id));
  262. return context.inst_block_stack().Pop();
  263. }
  264. // Builds and returns an eval block, given the list of canonical symbolic
  265. // constants that the instructions in the eval block should produce. This is
  266. // used when importing a generic.
  267. auto RebuildGenericEvalBlock(Context& context, SemIR::GenericId generic_id,
  268. SemIR::GenericInstIndex::Region region,
  269. llvm::ArrayRef<SemIR::InstId> const_ids)
  270. -> SemIR::InstBlockId {
  271. context.inst_block_stack().Push();
  272. ConstantsInGenericMap constants_in_generic;
  273. // For the definition region, populate constants from the declaration.
  274. if (region == SemIR::GenericInstIndex::Region::Definition) {
  275. PopulateConstantsFromDeclaration(context, generic_id, constants_in_generic);
  276. }
  277. constants_in_generic.GrowForInsertCount(const_ids.size());
  278. for (auto [i, inst_id] : llvm::enumerate(const_ids)) {
  279. // Build a constant in the inst block.
  280. AddGenericConstantToEvalBlock(context, generic_id, region,
  281. constants_in_generic, inst_id);
  282. CARBON_CHECK(
  283. context.inst_block_stack().PeekCurrentBlockContents().size() == i + 1,
  284. "Produced {0} instructions when importing {1}",
  285. (context.inst_block_stack().PeekCurrentBlockContents().size() - i),
  286. context.insts().Get(inst_id));
  287. }
  288. return context.inst_block_stack().Pop();
  289. }
  290. auto DiscardGenericDecl(Context& context) -> void {
  291. context.generic_region_stack().Pop();
  292. }
  293. auto BuildGeneric(Context& context, SemIR::InstId decl_id) -> SemIR::GenericId {
  294. auto all_bindings =
  295. context.scope_stack().compile_time_bindings_stack().PeekAllValues();
  296. if (all_bindings.empty()) {
  297. CARBON_CHECK(context.generic_region_stack().PeekDependentInsts().empty(),
  298. "Have dependent instruction {0} in declaration {1} but no "
  299. "compile time bindings are in scope.",
  300. context.insts().Get(context.generic_region_stack()
  301. .PeekDependentInsts()
  302. .front()
  303. .inst_id),
  304. context.insts().Get(decl_id));
  305. context.generic_region_stack().Pop();
  306. return SemIR::GenericId::None;
  307. }
  308. // Build the new Generic object. Note that we intentionally do not hold a
  309. // persistent reference to it throughout this function, because the `generics`
  310. // collection can have items added to it by import resolution while we are
  311. // building this generic.
  312. auto bindings_id = context.inst_blocks().Add(all_bindings);
  313. SemIR::GenericId generic_id = context.generics().Add(
  314. SemIR::Generic{.decl_id = decl_id,
  315. .bindings_id = bindings_id,
  316. .self_specific_id = SemIR::SpecificId::None});
  317. // MakeSelfSpecificId could cause something to be imported, which would
  318. // invalidate the return value of `context.generics().Get(generic_id)`.
  319. auto self_specific_id = MakeSelfSpecificId(context, generic_id);
  320. context.generics().Get(generic_id).self_specific_id = self_specific_id;
  321. return generic_id;
  322. }
  323. auto FinishGenericDecl(Context& context, SemIRLoc loc,
  324. SemIR::GenericId generic_id) -> void {
  325. if (!generic_id.has_value()) {
  326. return;
  327. }
  328. auto decl_block_id = MakeGenericEvalBlock(
  329. context, generic_id, SemIR::GenericInstIndex::Region::Declaration);
  330. context.generic_region_stack().Pop();
  331. context.generics().Get(generic_id).decl_block_id = decl_block_id;
  332. ResolveSpecificDeclaration(context, loc,
  333. context.generics().GetSelfSpecific(generic_id));
  334. }
  335. auto BuildGenericDecl(Context& context, SemIR::InstId decl_id)
  336. -> SemIR::GenericId {
  337. SemIR::GenericId generic_id = BuildGeneric(context, decl_id);
  338. if (generic_id.has_value()) {
  339. FinishGenericDecl(context, decl_id, generic_id);
  340. }
  341. return generic_id;
  342. }
  343. auto FinishGenericRedecl(Context& context, SemIR::InstId /*decl_id*/,
  344. SemIR::GenericId /*generic_id*/) -> void {
  345. // TODO: Compare contents of this declaration with the existing one on the
  346. // generic.
  347. context.generic_region_stack().Pop();
  348. }
  349. auto FinishGenericDefinition(Context& context, SemIR::GenericId generic_id)
  350. -> void {
  351. if (!generic_id.has_value()) {
  352. // TODO: We can have symbolic constants in a context that had a non-generic
  353. // declaration, for example if there's a local generic let binding in a
  354. // function definition. Handle this case somehow -- perhaps by forming
  355. // substituted constant values now.
  356. context.generic_region_stack().Pop();
  357. return;
  358. }
  359. auto definition_block_id = MakeGenericEvalBlock(
  360. context, generic_id, SemIR::GenericInstIndex::Region::Definition);
  361. context.generics().Get(generic_id).definition_block_id = definition_block_id;
  362. context.generic_region_stack().Pop();
  363. }
  364. static auto ResolveSpecificDeclaration(Context& context, SemIRLoc loc,
  365. SemIR::SpecificId specific_id) -> void {
  366. // If this is the first time we've formed this specific, evaluate its decl
  367. // block to form information about the specific.
  368. if (!context.specifics().Get(specific_id).decl_block_id.has_value()) {
  369. // Set a placeholder value as the decl block ID so we won't attempt to
  370. // recursively resolve the same specific.
  371. context.specifics().Get(specific_id).decl_block_id =
  372. SemIR::InstBlockId::Empty;
  373. auto decl_block_id =
  374. TryEvalBlockForSpecific(context, loc, specific_id,
  375. SemIR::GenericInstIndex::Region::Declaration);
  376. // Note that TryEvalBlockForSpecific may reallocate the list of specifics,
  377. // so re-lookup the specific here.
  378. context.specifics().Get(specific_id).decl_block_id = decl_block_id;
  379. }
  380. }
  381. auto MakeSpecific(Context& context, SemIRLoc loc, SemIR::GenericId generic_id,
  382. SemIR::InstBlockId args_id) -> SemIR::SpecificId {
  383. auto specific_id = context.specifics().GetOrAdd(generic_id, args_id);
  384. ResolveSpecificDeclaration(context, loc, specific_id);
  385. return specific_id;
  386. }
  387. auto MakeSpecific(Context& context, SemIRLoc loc, SemIR::GenericId generic_id,
  388. llvm::ArrayRef<SemIR::InstId> args) -> SemIR::SpecificId {
  389. auto args_id = context.inst_blocks().AddCanonical(args);
  390. return MakeSpecific(context, loc, generic_id, args_id);
  391. }
  392. static auto MakeSelfSpecificId(Context& context, SemIR::GenericId generic_id)
  393. -> SemIR::SpecificId {
  394. if (!generic_id.has_value()) {
  395. return SemIR::SpecificId::None;
  396. }
  397. auto& generic = context.generics().Get(generic_id);
  398. auto args = context.inst_blocks().Get(generic.bindings_id);
  399. // Form a canonical argument list for the generic.
  400. llvm::SmallVector<SemIR::InstId> arg_ids;
  401. arg_ids.reserve(args.size());
  402. for (auto arg_id : args) {
  403. arg_ids.push_back(context.constant_values().GetConstantInstId(arg_id));
  404. }
  405. auto args_id = context.inst_blocks().AddCanonical(arg_ids);
  406. return context.specifics().GetOrAdd(generic_id, args_id);
  407. }
  408. auto MakeSelfSpecific(Context& context, SemIRLoc loc,
  409. SemIR::GenericId generic_id) -> SemIR::SpecificId {
  410. // Build a corresponding specific.
  411. SemIR::SpecificId specific_id = MakeSelfSpecificId(context, generic_id);
  412. // TODO: This could be made more efficient. We don't need to perform
  413. // substitution here; we know we want identity mappings for all constants and
  414. // types. We could also consider not storing the mapping at all in this case.
  415. ResolveSpecificDeclaration(context, loc, specific_id);
  416. return specific_id;
  417. }
  418. auto ResolveSpecificDefinition(Context& context, SemIRLoc loc,
  419. SemIR::SpecificId specific_id) -> bool {
  420. // TODO: Handle recursive resolution of the same generic definition.
  421. auto& specific = context.specifics().Get(specific_id);
  422. auto generic_id = specific.generic_id;
  423. CARBON_CHECK(generic_id.has_value(), "Specific with no generic ID");
  424. if (!specific.definition_block_id.has_value()) {
  425. // Evaluate the eval block for the definition of the generic.
  426. auto& generic = context.generics().Get(generic_id);
  427. if (!generic.definition_block_id.has_value()) {
  428. // The generic is not defined yet.
  429. return false;
  430. }
  431. auto definition_block_id = TryEvalBlockForSpecific(
  432. context, loc, specific_id, SemIR::GenericInstIndex::Region::Definition);
  433. // Note that TryEvalBlockForSpecific may reallocate the list of specifics,
  434. // so re-lookup the specific here.
  435. context.specifics().Get(specific_id).definition_block_id =
  436. definition_block_id;
  437. }
  438. return true;
  439. }
  440. auto GetInstForSpecific(Context& context, SemIR::SpecificId specific_id)
  441. -> SemIR::InstId {
  442. CARBON_CHECK(specific_id.has_value());
  443. const auto& specific = context.specifics().Get(specific_id);
  444. const auto& generic = context.generics().Get(specific.generic_id);
  445. auto decl = context.insts().Get(generic.decl_id);
  446. CARBON_KIND_SWITCH(decl) {
  447. case CARBON_KIND(SemIR::ClassDecl class_decl): {
  448. return context.types().GetInstId(
  449. GetClassType(context, class_decl.class_id, specific_id));
  450. }
  451. case CARBON_KIND(SemIR::InterfaceDecl interface_decl): {
  452. return context.types().GetInstId(
  453. GetInterfaceType(context, interface_decl.interface_id, specific_id));
  454. }
  455. case SemIR::FunctionDecl::Kind: {
  456. return context.constant_values().GetInstId(TryEvalInst(
  457. context, SemIR::InstId::None,
  458. SemIR::SpecificFunction{
  459. .type_id = GetSingletonType(
  460. context, SemIR::SpecificFunctionType::SingletonInstId),
  461. .callee_id = generic.decl_id,
  462. .specific_id = specific_id}));
  463. }
  464. case SemIR::AssociatedConstantDecl::Kind: {
  465. // TODO: We don't have a good instruction to use here.
  466. return generic.decl_id;
  467. }
  468. default: {
  469. CARBON_FATAL("Unknown kind for generic declaration {0}", decl);
  470. }
  471. }
  472. }
  473. } // namespace Carbon::Check