[clang] [Clang] Implement P2809: Trivial infinite loops are not Undefined Behavior (PR #90066)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 1 03:37:13 PDT 2024


================
@@ -908,6 +908,74 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
     incrementProfileCounter(&S);
 }
 
+bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression,
+                                              bool IsTrivialCXXLoop) {
+  if (CGM.getCodeGenOpts().getFiniteLoops() ==
+      CodeGenOptions::FiniteLoopsKind::Never)
+    return false;
+
+  if (CGM.getCodeGenOpts().getFiniteLoops() ==
+          CodeGenOptions::FiniteLoopsKind::Always &&
+      !getLangOpts().CPlusPlus11)
----------------
cor3ntin wrote:

Done!

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


More information about the cfe-commits mailing list