Home / Function/ removeUnnecessaryTryCatch() — react Function Reference

removeUnnecessaryTryCatch() — react Function Reference

Architecture documentation for the removeUnnecessaryTryCatch() function in HIRBuilder.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  c678dac0_f0b5_fd43_e8fe_97067c37de7d["removeUnnecessaryTryCatch()"]
  df6865e0_b573_e905_84d6_4eb6b419a888["HIRBuilder.ts"]
  c678dac0_f0b5_fd43_e8fe_97067c37de7d -->|defined in| df6865e0_b573_e905_84d6_4eb6b419a888
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391["build()"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|calls| c678dac0_f0b5_fd43_e8fe_97067c37de7d
  fbdc3953_3621_331c_a5b1_d3199bea5254["constantPropagationImpl()"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|calls| c678dac0_f0b5_fd43_e8fe_97067c37de7d
  82b1d221_48c8_7d34_669c_abce4ff71f21["pruneMaybeThrows()"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|calls| c678dac0_f0b5_fd43_e8fe_97067c37de7d
  d0270ab6_a621_bd55_a1b9_a5cad8b406b2["makeInstructionId()"]
  c678dac0_f0b5_fd43_e8fe_97067c37de7d -->|calls| d0270ab6_a621_bd55_a1b9_a5cad8b406b2
  style c678dac0_f0b5_fd43_e8fe_97067c37de7d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts lines 877–904

export function removeUnnecessaryTryCatch(fn: HIR): void {
  for (const [, block] of fn.blocks) {
    if (
      block.terminal.kind === 'try' &&
      !fn.blocks.has(block.terminal.handler)
    ) {
      const handlerId = block.terminal.handler;
      const fallthroughId = block.terminal.fallthrough;
      const fallthrough = fn.blocks.get(fallthroughId);
      block.terminal = {
        kind: 'goto',
        block: block.terminal.block,
        id: makeInstructionId(0),
        loc: block.terminal.loc,
        variant: GotoVariant.Break,
      };

      if (fallthrough != null) {
        if (fallthrough.preds.size === 1 && fallthrough.preds.has(handlerId)) {
          // delete fallthrough
          fn.blocks.delete(fallthroughId);
        } else {
          fallthrough.preds.delete(handlerId);
        }
      }
    }
  }
}

Subdomains

Frequently Asked Questions

What does removeUnnecessaryTryCatch() do?
removeUnnecessaryTryCatch() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts.
Where is removeUnnecessaryTryCatch() defined?
removeUnnecessaryTryCatch() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts at line 877.
What does removeUnnecessaryTryCatch() call?
removeUnnecessaryTryCatch() calls 1 function(s): makeInstructionId.
What calls removeUnnecessaryTryCatch()?
removeUnnecessaryTryCatch() is called by 3 function(s): build, constantPropagationImpl, pruneMaybeThrows.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free