[clang] [Clang] [CodeGen] Avoid constant folding when DeclRefExpr references a captured variable (PR #192704)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 11:00:06 PDT 2026


================
@@ -3574,7 +3605,9 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
     // constant value directly instead.
     if (E->isNonOdrUse() == NOUR_Constant &&
----------------
efriedma-quic wrote:

I guess the reasoning here is basically, if there's a capture, we must have captured it for a reason... which makes sense, I guess.

Is refersToEnclosingVariableOrCapture() not sufficient to check for this case?

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


More information about the cfe-commits mailing list