[clang] [CIR] -Wreturn-type (1/2): Add an analysis classifying how control reaches a function's end (PR #239774)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 20:29:03 PST 2026


================
@@ -0,0 +1,681 @@
+//===- CIRFunctionExitAnalysis.cpp - How control leaves a function --------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// A reachability walk over structured CIR. Each region reports how control
+// leaves it (falling through, break, continue, explicit return, or reaching an
+// `implicit` terminator). Operations implementing RegionBranchOpInterface are
+// walked through their region successors, narrowed by constant operands;
+// break, continue, switches and cleanup scopes are handled on their own.
+// Reachable noreturn calls, user traps and throws are one more kind of exit,
+// the edges CheckFallThrough uses to tell MaybeFallThrough from
+// AlwaysFallThrough.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/CIR/Dialect/Analysis/CIRFunctionExitAnalysis.h"
+
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/Remarks.h"
+#include "mlir/IR/Threading.h"
+#include "mlir/Interfaces/ControlFlowInterfaces.h"
+#include "clang/CIR/Dialect/Analysis/CIRConstantFolding.h"
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "llvm/ADT/BitmaskEnum.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/TypeSwitch.h"
+#include "llvm/Support/Threading.h"
+#include "llvm/Support/TimeProfiler.h"
+
+using namespace cir;
+
+namespace {
+
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+
+/// How control can leave a region or a structured operation.
+enum class Exits : uint8_t {
+  None = 0,
+  /// Falls through to the next operation.
+  Normal = 1 << 0,
+  /// `cir.break` out of the enclosing loop or switch.
+  Break = 1 << 1,
+  /// `cir.continue` to the next loop iteration.
+  Continue = 1 << 2,
+  /// `cir.return` from a return statement, or `cir.co_return`.
+  ExplicitReturn = 1 << 3,
+  /// Reaches the implicit `cir.return` at the end of the body.
+  ImplicitReturn = 1 << 4,
+  /// Noreturn call, trap, throw or `__builtin_unreachable`.
+  NoReturn = 1 << 5,
+  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/NoReturn)
+};
+
+} // namespace
+
+/// The exits that leave the whole function.
+static constexpr Exits functionExits =
+    Exits::ExplicitReturn | Exits::ImplicitReturn | Exits::NoReturn;
+
+/// The exits that leave an enclosing operation too, not just the region.
+static constexpr Exits escapingExits =
+    Exits::Break | Exits::Continue | functionExits;
+
+/// Whether control may leave through any of `kinds`.
+static bool mayExitVia(Exits exits, Exits kinds) {
+  return (exits & kinds) != Exits::None;
+}
+
+namespace {
+
+/// The labels whose address a global takes, by function. Collected once per
+/// module, when an analysis first reaches an indirect goto; thread-safe.
+class GlobalBlockAddresses {
+public:
+  explicit GlobalBlockAddresses(mlir::ModuleOp module) : module(module) {}
+
+  llvm::ArrayRef<mlir::StringAttr> lookup(mlir::StringAttr func) {
+    llvm::call_once(collected, [&] { collect(); });
+    auto it = labels.find(func);
+    return it == labels.end() ? llvm::ArrayRef<mlir::StringAttr>() : it->second;
+  }
+
+private:
+  void collect() {
+    if (!module)
+      return;
+    for (GlobalOp global : module.getOps<GlobalOp>())
+      global->walk([&](mlir::Operation *op) {
+        walkBlockAddressLabels(
+            op, [&](mlir::StringAttr func, mlir::StringAttr label) {
+              labels[func].push_back(label);
+            });
+      });
+  }
+
+  mlir::ModuleOp module;
+  llvm::once_flag collected;
+  llvm::DenseMap<mlir::StringAttr, llvm::SmallVector<mlir::StringAttr>> labels;
+};
+
+/// The labels gotos can reach. A reached goto may target a label in a region
+/// a walk saw as dead, so the function is walked again until no new label
+/// becomes a target.
+class GotoTargets {
+public:
+  GotoTargets(FuncOp func, GlobalBlockAddresses &globalAddresses)
+      : func(func), globalAddresses(globalAddresses) {}
+
+  /// Forget the gotos the previous walk reached.
+  void startWalk() {
+    reachedGotos.clear();
+    reachedIndirectGoto = false;
+  }
+  void addReachedGoto(GotoOp op) { reachedGotos.insert(op.getLabelAttr()); }
+  /// A cir.indirect_goto can reach every label whose address is taken.
+  void addReachedIndirectGoto() { reachedIndirectGoto = true; }
+  /// Add the labels the walk's gotos target; whether any of them is new.
+  bool finishWalk();
+
+  bool empty() const { return targets.empty(); }
+  bool isTarget(mlir::Operation *op) const {
+    auto label = mlir::dyn_cast<LabelOp>(op);
+    return label && targets.contains(label.getLabelAttr());
+  }
+  /// Whether a target is nested in `op`, so a dead `op` still needs a visit.
+  bool enclosesTarget(mlir::Operation *op) const {
+    return targetAncestors.contains(op);
+  }
+
+private:
+  void addAddressTakenLabels();
+  void updateTargetAncestors();
+
+  FuncOp func;
+  GlobalBlockAddresses &globalAddresses;
+  llvm::DenseSet<mlir::StringAttr> targets;
+  llvm::DenseSet<mlir::Operation *> targetAncestors;
+  llvm::DenseSet<mlir::StringAttr> reachedGotos;
+  bool reachedIndirectGoto = false;
+  bool addedAddressTakenLabels = false;
+  /// The function's labels, collected once a goto makes them matter. Never
+  /// empty after that, since a goto only targets a label of this function.
+  llvm::SmallVector<LabelOp> labels;
+};
+
+class FunctionExitAnalyzer {
+public:
+  FunctionExitAnalyzer(FuncOp func, GlobalBlockAddresses &globalAddresses)
+      : func(func), gotoTargets(func, globalAddresses) {}
+
+  FunctionExitKind run();
+
+private:
+  using BranchTerminators =
+      llvm::SmallVectorImpl<mlir::RegionBranchTerminatorOpInterface>;
+
+  /// With `branchTerms`, the reached region branch terminators are collected
+  /// there; otherwise reaching one is a Normal exit.
+  Exits visitRegion(mlir::Region &region, bool entered,
+                    BranchTerminators *branchTerms = nullptr);
+  Exits visitStructured(mlir::Operation *op, bool entered);
+  Exits visitRegionBranch(mlir::RegionBranchOpInterface op, bool entered);
+  Exits visitSwitch(SwitchOp op, bool entered);
+  Exits visitCleanupScope(CleanupScopeOp op, bool entered);
+  void visitTerminator(mlir::Operation *op, Exits &exits,
+                       llvm::SmallVectorImpl<mlir::Block *> &liveSuccessors,
+                       BranchTerminators *branchTerms);
+
+  FuncOp func;
+  GotoTargets gotoTargets;
+  ConstantFolder folder;
+  /// The enclosing switches, innermost last. A reachable switch dispatches to
+  /// all of its cases, wherever they are nested in its body.
+  struct SwitchState {
+    bool entered = false;
+    bool hasDefault = false;
+  };
+  llvm::SmallVector<SwitchState> switches;
+
+  /// Makes a switch the innermost one while it is in scope.
+  class SwitchScope {
+  public:
+    SwitchScope(FunctionExitAnalyzer &analyzer, bool entered)
+        : switches(analyzer.switches) {
+      switches.push_back({entered, /*hasDefault=*/false});
+    }
+    SwitchScope(const SwitchScope &) = delete;
+    SwitchScope &operator=(const SwitchScope &) = delete;
+    ~SwitchScope() { switches.pop_back(); }
+
+    /// Whether a default case was dispatched to so far.
+    bool hasDefault() const { return switches.back().hasDefault; }
+
+  private:
+    llvm::SmallVector<SwitchState> &switches;
+  };
+
+  bool inEnteredSwitch() const {
+    return !switches.empty() && switches.back().entered;
+  }
+};
+
+} // namespace
+
+/// The constant values of `op`'s operands, null where unknown, as the region
+/// branch interfaces take them. Only conditions select successors, so only
+/// `!cir.bool` operands are folded.
+static llvm::SmallVector<mlir::Attribute>
+getConstantOperands(ConstantFolder &folder, mlir::Operation *op) {
+  return llvm::map_to_vector(op->getOperands(), [&](mlir::Value value) {
+    return mlir::isa<BoolType>(value.getType()) ? folder.fold(value)
+                                                : mlir::Attribute();
+  });
+}
+
+/// Where a `cir.continue` in `loop`'s body goes: where the end of the body
+/// goes.
+static mlir::Region &getLatch(LoopOpInterface loop) {
+  if (mlir::Region *step = loop.maybeGetStep())
+    return *step;
+  if (mlir::Region *cleanup = loop.maybeGetCleanup())
+    return *cleanup;
+  return loop.getCond();
+}
+
+/// Whether `op` is a call known not to return, e.g. to a [[noreturn]]
+/// function.
+static bool isNoReturnCall(mlir::Operation *op) {
+  auto call = mlir::dyn_cast<CIRCallOpInterface>(op);
+  return call && call.isNoReturn();
+}
+
+/// `__builtin_assume(0)` is noreturn for the CFG check.
+static bool isAssumeFalse(ConstantFolder &folder, mlir::Operation *op) {
+  auto assume = mlir::dyn_cast<AssumeOp>(op);
+  return assume && folder.foldBool(assume.getPredicate()) == false;
+}
+
+/// The only operation with regions in a single-block \p region, if any.
+static mlir::Operation *getOnlyRegionOp(mlir::Region &region) {
+  if (!region.hasOneBlock())
+    return nullptr;
+  mlir::Operation *found = nullptr;
+  for (mlir::Operation &op : region.front()) {
+    if (op.getNumRegions() == 0)
+      continue;
+    if (found)
+      return nullptr;
+    found = &op;
+  }
+  return found;
+}
+
+/// The code written in a coroutine's body, without the implicit `try` (and the
+/// `if` around it) CIRGen adds with exceptions: leaving those is not reaching
+/// the end of the body.
+// TODO: Drop this once CIRGen emits that handling in the coroutine's planned
+// `unwind` region, leaving only the user's code in `body`.
+static mlir::Region &getCoroutineUserBody(CoroutineOp coro) {
+  mlir::Operation *op = getOnlyRegionOp(coro.getBody());
+  if (auto ifOp = mlir::dyn_cast_if_present<IfOp>(op);
+      ifOp && ifOp.getElseRegion().empty())
+    op = getOnlyRegionOp(ifOp.getThenRegion());
+  if (auto scope = mlir::dyn_cast_if_present<ScopeOp>(op))
+    op = getOnlyRegionOp(scope.getScopeRegion());
+  if (auto tryOp = mlir::dyn_cast_if_present<TryOp>(op))
+    return tryOp.getTryRegion();
+  return coro.getBody();
+}
+
+FunctionExitKind FunctionExitAnalyzer::run() {
+  // For a coroutine, the end is that of the code written in its body, and
+  // co_return is its return.
+  mlir::Region *body = &func.getBody();
+  if (func.getCoroutineKind().has_value()) {
+    CoroutineOp coro;
+    func.walk<mlir::WalkOrder::PreOrder>([&](CoroutineOp op) {
+      coro = op;
+      return mlir::WalkResult::interrupt();
+    });
+    if (!coro)
+      return FunctionExitKind::Unknown;
+    body = &getCoroutineUserBody(coro);
+  }
+
+  // Without gotos, one walk.
+  Exits exits;
+  do {
+    gotoTargets.startWalk();
+    exits = visitRegion(*body, /*entered=*/true);
+  } while (gotoTargets.finishWalk());
+
+  bool explicitReturn = mayExitVia(exits, Exits::ExplicitReturn);
+  if (!mayExitVia(exits, Exits::Normal | Exits::ImplicitReturn))
+    return explicitReturn ? FunctionExitKind::ReturnOnly
+                          : FunctionExitKind::NoReturn;
+  if (explicitReturn || mayExitVia(exits, Exits::NoReturn))
+    return FunctionExitKind::MayReachEnd;
+  return FunctionExitKind::MustReachEnd;
+}
+
+bool GotoTargets::finishWalk() {
+  size_t numTargets = targets.size();
+  targets.insert_range(reachedGotos);
+  if (reachedIndirectGoto)
+    addAddressTakenLabels();
+  if (targets.size() == numTargets)
+    return false;
+  updateTargetAncestors();
+  return true;
+}
+
+void GotoTargets::addAddressTakenLabels() {
+  if (addedAddressTakenLabels)
+    return;
+  addedAddressTakenLabels = true;
+  mlir::StringAttr funcName = func.getSymNameAttr();
+  auto addFromOp = [&](mlir::Operation *op) {
+    walkBlockAddressLabels(
+        op, [&](mlir::StringAttr labelFunc, mlir::StringAttr label) {
+          if (labelFunc == funcName)
+            targets.insert(label);
+        });
+  };
+  func.getBody().walk(addFromOp);
+  // As in the CFG, addresses taken in static initializers count too.
+  targets.insert_range(globalAddresses.lookup(funcName));
+}
+
+void GotoTargets::updateTargetAncestors() {
+  if (labels.empty())
+    func.getBody().walk([&](LabelOp label) { labels.push_back(label); });
+  targetAncestors.clear();
+  for (LabelOp label : labels) {
+    if (!targets.contains(label.getLabelAttr()))
+      continue;
+    for (mlir::Operation *parent = label->getParentOp(); parent != func;
+         parent = parent->getParentOp())
+      if (!targetAncestors.insert(parent).second)
+        break;
+  }
+}
+
+Exits FunctionExitAnalyzer::visitRegion(mlir::Region &region, bool entered,
+                                        BranchTerminators *branchTerms) {
+  if (region.empty())
+    return entered ? Exits::Normal : Exits::None;
+
+  // Dead code is still walked when a goto or a switch dispatch may enter it,
+  // and walked again if it turns out live.
+  bool mayHideCase = inEnteredSwitch();
+  auto mustVisitDead = [&](mlir::Operation &op) {
+    return (mayHideCase && op.getNumRegions() != 0) ||
+           gotoTargets.enclosesTarget(&op);
+  };
+  // Most regions have a single block, which an inline map holds without
+  // allocating.
+  Exits exits = Exits::None;
+  llvm::SmallDenseMap<mlir::Block *, bool, 4> visited;
+  llvm::SmallVector<std::pair<mlir::Block *, bool>> worklist;
+  worklist.push_back({&region.front(), entered});
+  if (!region.hasOneBlock() && (mayHideCase || !gotoTargets.empty()))
+    for (mlir::Block &block : llvm::drop_begin(region))
+      if (llvm::any_of(block, [&](mlir::Operation &op) {
+            return gotoTargets.isTarget(&op) || mustVisitDead(op);
+          }))
+        worklist.push_back({&block, false});
+
+  while (!worklist.empty()) {
+    auto [block, live] = worklist.pop_back_val();
+    auto [it, inserted] = visited.try_emplace(block, live);
+    if (!inserted) {
+      if (it->second || !live)
+        continue;
+      it->second = true;
+    }
+
+    // Querying the terminator trait once per block rather than per operation
+    // is measurably faster.
+    mlir::Operation *terminator =
+        block->mightHaveTerminator() ? &block->back() : nullptr;
+    llvm::SmallVector<mlir::Block *> liveSuccessors;
+    for (mlir::Operation &op : *block) {
+      if (!live) {
+        if (gotoTargets.isTarget(&op)) {
+          live = true;
+          continue;
+        }
+        if (!mustVisitDead(op))
+          continue;
+      }
+
+      if (op.getNumRegions() != 0) {
+        Exits opExits = visitStructured(&op, live);
+        exits |= opExits & escapingExits;
+        live = mayExitVia(opExits, Exits::Normal);
+        continue;
+      }
+
+      if (!live)
+        continue;
+
+      if (isNoReturnCall(&op) || isAssumeFalse(folder, &op) ||
+          mlir::isa<ThrowOp>(op)) {
+        exits |= Exits::NoReturn;
+        // A noreturn cir.try_call may still unwind.
+        if (auto tryCall = mlir::dyn_cast<TryCallOp>(op))
+          liveSuccessors.push_back(tryCall.getUnwindDest());
+        live = false;
+      } else if (&op == terminator) {
+        visitTerminator(&op, exits, liveSuccessors, branchTerms);
+        live = false;
+      }
+    }
+
+    // A block without a terminator falls through to the region's parent.
+    if (live)
+      exits |= Exits::Normal;
+
+    for (mlir::Block *succ : liveSuccessors)
+      worklist.push_back({succ, true});
+  }
+  return exits;
+}
+
+void FunctionExitAnalyzer::visitTerminator(
+    mlir::Operation *op, Exits &exits,
+    llvm::SmallVectorImpl<mlir::Block *> &liveSuccessors,
+    BranchTerminators *branchTerms) {
+  llvm::TypeSwitch<mlir::Operation *>(op)
+      // cir.resume unwinds: its edge to the parent is not a normal exit.
+      .Case<ResumeOp>([](ResumeOp) {})
+      // Check the terminators leaving the function first: some are
+      // ReturnLike, and so region branch terminators too.
+      .Case<CoReturnOp>([&](CoReturnOp) { exits |= Exits::ExplicitReturn; })
+      .Case<ReturnOp>([&](ReturnOp ret) {
+        exits |=
+            ret.getImplicit() ? Exits::ImplicitReturn : Exits::ExplicitReturn;
+      })
+      // User traps and __builtin_unreachable are noreturn, like in the CFG.
+      .Case<TrapOp, UnreachableOp>([&](auto term) {
+        exits |= term.getImplicit() ? Exits::ImplicitReturn : Exits::NoReturn;
+      })
+      .Case<mlir::RegionBranchTerminatorOpInterface>([&](auto branchTerm) {
+        if (branchTerms)
+          branchTerms->push_back(branchTerm);
+        else
+          exits |= Exits::Normal;
+      })
+      .Case<BreakOp>([&](BreakOp) { exits |= Exits::Break; })
+      .Case<ContinueOp>([&](ContinueOp) { exits |= Exits::Continue; })
+      .Case<BrCondOp>([&](BrCondOp brCond) {
+        std::optional<bool> value = folder.foldBool(brCond.getCond());
+        if (value != false)
+          liveSuccessors.push_back(brCond.getDestTrue());
+        if (value != true)
+          liveSuccessors.push_back(brCond.getDestFalse());
+      })
+      .Case<GotoOp>([&](GotoOp gotoOp) { gotoTargets.addReachedGoto(gotoOp); })
+      .Case<IndirectGotoOp>(
+          [&](IndirectGotoOp) { gotoTargets.addReachedIndirectGoto(); })
+      // Everything else with successors (cir.br, cir.switch.flat, ...)
+      // reaches all of them.
+      .Default([&](mlir::Operation *op) {
+        llvm::append_range(liveSuccessors, op->getSuccessors());
+      });
+}
+
+Exits FunctionExitAnalyzer::visitStructured(mlir::Operation *op, bool entered) {
+  if (auto switchOp = mlir::dyn_cast<SwitchOp>(op))
+    return visitSwitch(switchOp, entered);
+  if (auto cleanupScope = mlir::dyn_cast<CleanupScopeOp>(op))
+    return visitCleanupScope(cleanupScope, entered);
+
+  if (auto caseOp = mlir::dyn_cast<CaseOp>(op)) {
+    // A case is entered by falling through from the previous one or by the
+    // switch dispatching to it.
+    bool dispatched = inEnteredSwitch();
+    if (dispatched && caseOp.getKind() == CaseOpKind::Default)
+      switches.back().hasDefault = true;
+    return visitRegion(caseOp.getCaseRegion(), entered || dispatched);
+  }
+
+  // The region successors of other dialects' operations may end in
+  // terminators this analysis does not know.
+  auto regionBranch = mlir::dyn_cast<mlir::RegionBranchOpInterface>(op);
+  if (regionBranch && mlir::isa<CIRDialect>(op->getDialect()))
+    return visitRegionBranch(regionBranch, entered);
+
+  // Anything else completes whenever reached.
+  Exits exits = entered ? Exits::Normal : Exits::None;
+  for (mlir::Region &region : op->getRegions())
+    exits |= visitRegion(region, entered) & escapingExits;
+  return exits;
+}
+
+Exits FunctionExitAnalyzer::visitRegionBranch(mlir::RegionBranchOpInterface op,
+                                              bool entered) {
+  enum class Visit : uint8_t { None, Dead, Live };
+  llvm::SmallVector<Visit, 4> visits(op->getNumRegions(), Visit::None);
+  llvm::SmallVector<std::pair<mlir::Region *, bool>, 4> worklist;
+  bool completes = false;
+  auto addSuccessors = [&](llvm::ArrayRef<mlir::RegionSuccessor> successors) {
+    for (const mlir::RegionSuccessor &successor : successors) {
+      if (successor.isOperation())
+        completes = true;
+      else if (visits[successor.getSuccessor()->getRegionNumber()] !=
+               Visit::Live)
+        worklist.push_back({successor.getSuccessor(), true});
+    }
+  };
+
+  llvm::SmallVector<mlir::RegionSuccessor> successors;
+  if (entered) {
+    op.getEntrySuccessorRegions(getConstantOperands(folder, op), successors);
+    addSuccessors(successors);
+  }
+
+  // Regions control does not enter are still walked when a goto or a switch
+  // dispatch may enter them.
+  bool mayVisitDead = inEnteredSwitch() || gotoTargets.enclosesTarget(op);
+  auto loop = mlir::dyn_cast<LoopOpInterface>(op.getOperation());
+  Exits exits = Exits::None;
+  while (true) {
+    while (!worklist.empty()) {
+      auto [region, live] = worklist.pop_back_val();
+      Visit &visit = visits[region->getRegionNumber()];
+      if (visit == Visit::Live || (visit == Visit::Dead && !live))
+        continue;
+      visit = live ? Visit::Live : Visit::Dead;
+
+      llvm::SmallVector<mlir::RegionBranchTerminatorOpInterface> branchTerms;
+      Exits regionExits = visitRegion(*region, live, &branchTerms);
+      exits |= regionExits & escapingExits;
+      // Falling off the end of a region returns to the operation.
+      if (mayExitVia(regionExits, Exits::Normal))
+        completes = true;
+      for (mlir::RegionBranchTerminatorOpInterface term : branchTerms) {
+        llvm::SmallVector<mlir::Attribute> operands =
+            getConstantOperands(folder, term);
+        successors.clear();
+        term.getSuccessorRegions(operands, successors);
+        // A loop condition keeps its exit for any cir.break in the body, but
+        // the reached breaks are already Break exits.
+        auto cond = mlir::isa<ConditionOp>(term)
+                        ? mlir::dyn_cast_if_present<BoolAttr>(operands.front())
+                        : BoolAttr();
+        if (loop && cond && cond.getValue())
+          llvm::erase_if(successors, [&](const mlir::RegionSuccessor &succ) {
+            return succ.getSuccessor() != &loop.getBody();
+          });
+        addSuccessors(successors);
+      }
+      if (loop && mayExitVia(regionExits, Exits::Continue))
+        addSuccessors(mlir::RegionSuccessor(&getLatch(loop)));
+    }
+
+    if (!entered || mayVisitDead) {
+      for (mlir::Region &region : op->getRegions())
+        if (visits[region.getRegionNumber()] == Visit::None)
+          worklist.push_back({&region, false});
+    }
+    if (worklist.empty())
+      break;
+  }
+
+  // Breaks and continues stop at a loop; what leaves the function leaves it.
+  if (loop) {
+    completes |= mayExitVia(exits, Exits::Break);
+    exits &= functionExits;
+  }
+  return completes ? exits | Exits::Normal : exits;
+}
+
+Exits FunctionExitAnalyzer::visitSwitch(SwitchOp op, bool entered) {
+  // The switch body is entered through its cases only, so code ahead of the
+  // first case is dead.
+  SwitchScope scope(*this, entered);
+  Exits bodyExits = visitRegion(op.getBody(), /*entered=*/false);
+
+  // Breaks stop at the switch; continues and what leaves the function leave
+  // it.
+  Exits exits = bodyExits & (Exits::Continue | functionExits);
+  // As in the CFG check, a switch listing every enumerator has no implicit
+  // default edge.
+  if (mayExitVia(bodyExits, Exits::Normal | Exits::Break) ||
+      (entered && !scope.hasDefault() && !op.getAllEnumCasesCovered()))
----------------
bcardosolopes wrote:

Marked "NYI"

https://github.com/llvm/llvm-project/pull/239774


More information about the cfe-commits mailing list