================
@@ -2815,6 +2815,27 @@ static bool neverReturns(const CFGBlock *B) {
     if (isa<CXXThrowExpr>(S->getStmt()))
       return true;
   }
+
+  // If B constructed a temporary whose destructor is noreturn, control 
entering
+  // the decision block will always branch to the non-returning destructor.
+  if (B->succ_size() == 1) {
+    if (const CFGBlock *Succ = *B->succ_begin()) {
+      if (Succ->getTerminator().isTemporaryDtorsBranch() &&
+          !Succ->succ_empty()) {
+        // The decision block's terminator is the CXXBindTemporaryExpr; if B
+        // bound this temporary, entering Succ from B always takes dtor edge.
+        const Stmt *Term = Succ->getTerminatorStmt();
+        if (llvm::any_of(*B, [Term](const CFGElement &CE) {
+              auto CS = CE.getAs<CFGStmt>();
+              return CS && CS->getStmt() == Term;
+            })) {
+          if (const auto *DtorBlock = Succ->succ_begin()->getReachableBlock())
----------------
ziqingluo-90 wrote:

I see your tests only have no_return statements in the false branch. Is it on 
purpose?

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

Reply via email to