================
@@ -908,6 +908,69 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
     incrementProfileCounter(&S);
 }
 
+bool CodeGenFunction::checkIfLoopMustProgress(const Expr 
*ControllingExpression,
+                                              bool HasEmptyBody) {
+  if (CGM.getCodeGenOpts().getFiniteLoops() ==
+      CodeGenOptions::FiniteLoopsKind::Never)
+    return false;
+
+  // Now apply rules for plain C (see  6.8.5.6 in C11).
+  // Loops with constant conditions do not have to make progress in any C
+  // version.
+  // As an extension, we consisider loops whose constant expression
+  // can be constant-folded.
+  Expr::EvalResult Result;
+  bool CondIsConstInt =
----------------
efriedma-quic wrote:

So... we treat it as a manifestly constant-evaluated for the purpose of 
checking whether the loop is trivial, but then flips to not manifestly 
constant-evaluated for the actual evaluation at runtime?  The wording could use 
some clarification...

Due to the way Sema::CheckForImmediateInvocation works, once we decide an 
expression is not manifestly constant-evaluated, we can't actually 
constant-evaluate it, I think; the AST is modified.  Maybe we can run 
constant-evaluation before Sema::CheckForImmediateInvocation runs, though.

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

Reply via email to