================
@@ -1808,12 +1808,24 @@ struct CounterCoverageMappingBuilder
}
}
+private:
+ static bool evaluateConstantCondition(const Expr *Condition) {
+ if (const auto *Expr = dyn_cast<ConstantExpr>(Condition))
+ return Expr->getResultAsAPSInt().getExtValue();
+
+ if (const auto *Expr = dyn_cast<ExprWithCleanups>(Condition))
+ return evaluateConstantCondition(Expr->getSubExpr()); // recursion
+
+ assert(false && "Unexpected node in 'if constexpr' condition");
+ return false;
+ }
+
+public:
----------------
efriedma-quic wrote:
Can we just use IfStmt::getNondiscardedCase here?
More generally, we could add a method for evaluating ConstantExprs, I guess,
but IfStmt itself currently just uses EvaluateKnownConstInt, which should be
equivalent for the relevant cases.
https://github.com/llvm/llvm-project/pull/80292
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits