[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
Tue Oct 6 23:21:07 PDT 2026
================
@@ -1532,10 +1532,11 @@ const Stmt *LabelStmt::getInnermostLabeledStmt() const {
return S;
}
-const Stmt *LoopControlStmt::getNamedLoopOrSwitch() const {
- if (!hasLabelTarget())
- return nullptr;
- return getLabelDecl()->getStmt()->getInnermostLabeledStmt();
+const std::optional<Stmt *> LoopControlStmt::getNamedLoopOrSwitch() const {
----------------
tbaederr wrote:
I wasn't trying to say that the two invalid states are necessarily wrong, just that there are now two. From the docs of this function, it's not clear to me when it returns a non-`std::nullopt` but `nullptr` value.
https://github.com/llvm/llvm-project/pull/228655
More information about the cfe-commits
mailing list