================
@@ -2503,6 +2505,26 @@ Stmt *BlockExpr::getBody() {
 // Generic Expression Routines
 
//===----------------------------------------------------------------------===//
 
+bool Expr::mayBranchOut() const {
+  struct BranchDetector : public RecursiveASTVisitor<BranchDetector> {
+    bool HasBranch = false;
+    bool activate() {
+      HasBranch = true;
+      return false;
+    }
+    // Coroutine suspensions.
+    bool VisitCoawaitExpr(CoawaitExpr *) { return activate(); }
+    bool VisitCoyieldExpr(CoyieldExpr *) { return activate(); }
+    // Control flow in stmt-expressions.
+    bool VisitBreakStmt(BreakStmt *) { return activate(); }
+    bool VisitReturnStmt(ReturnStmt *) { return activate(); }
+    bool VisitGotoStmt(GotoStmt *) { return activate(); }
+  };
----------------
usx95 wrote:

I think it should be fine to stick to non-exceptional control flow out of this 
expression. `throw` or, for that matter, any call to a throwing function would 
be branching but that is already dealt with exceptions.

https://github.com/llvm/llvm-project/pull/85398
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to