================
@@ -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 {
----------------
ojhunt wrote:

I agree - I've used `optional<T*>` in a few places, but we really need 
{invalid, none, value} rather than `has_value()==false` implies error. 

I think such a type would be useful, but I think making that part of this PR is 
clearly overkill. The current query + check however seems particularly bad as 
well: simply null checking the return is easy but is incorrect, etc

https://github.com/llvm/llvm-project/pull/228655
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to