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

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 3 21:43:05 PDT 2026


================
@@ -3109,7 +3109,8 @@ class LoopControlStmt : public Stmt {
   void setLabelDecl(LabelDecl *S) { TargetLabel = S; }
 
   /// If this is a named break/continue, get the loop or switch statement
-  /// that this targets.
+  /// that this targets. May return null if the target LabelStmt has not
+  /// yet been created.
   const Stmt *getNamedLoopOrSwitch() const;
----------------
tbaederr wrote:

```suggestion
  /// \pre `hasLabelTarget()`
  const Stmt *getNamedLoopOrSwitch() const;
```

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


More information about the cfe-commits mailing list