[clang] [clang][AST] Fix crash on labeled break/continue within switch condition statement expression (PR #228655)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 4 17:23:31 PDT 2026


================
@@ -1533,9 +1533,9 @@ const Stmt *LabelStmt::getInnermostLabeledStmt() const {
 }
 
 const Stmt *LoopControlStmt::getNamedLoopOrSwitch() const {
-  if (!hasLabelTarget())
-    return nullptr;
-  return getLabelDecl()->getStmt()->getInnermostLabeledStmt();
+  assert(hasLabelTarget());
+  LabelStmt *Label = getLabelDecl()->getStmt();
+  return Label ? Label->getInnermostLabeledStmt() : nullptr;
----------------
ojhunt wrote:

`std::pair<bool, *>`? (a more general, well out of scope for this PR, option would be a result type)

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


More information about the cfe-commits mailing list