[clang] [clang][ExprConst] Fix second arg of __builtin_{clzg,ctzg} not always being evaluated (PR #86742)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 26 14:34:18 PDT 2024
================
@@ -12425,12 +12430,17 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
if (!EvaluateInteger(E->getArg(0), Val, Info))
return false;
+ std::optional<APSInt> Fallback;
+ if (BuiltinOp == Builtin::BI__builtin_ctzg && E->getNumArgs() > 1) {
+ APSInt FallbackTemp;
+ if (!EvaluateInteger(E->getArg(1), FallbackTemp, Info))
+ return false;
+ Fallback = FallbackTemp;
----------------
overmighty wrote:
I guess using a `bool HasFallback` instead of `std::optional` would be more efficient but defaulting to `std::optional` feels like better practice.
https://github.com/llvm/llvm-project/pull/86742
More information about the cfe-commits
mailing list