[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 14 02:18:50 PDT 2024
================
@@ -3420,6 +3441,15 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
}
Result = VD->getEvaluatedValue();
+
+ // P2280R4 If we don't have a value because this is a reference that was not
+ // initialized or whose lifetime began within E then create a value with as
+ // a ConstexprUnknown status.
+ if (AllowConstexprUnknown) {
+ if (!Result) {
+ Result = new APValue(Base, APValue::ConstexprUnknown{}, CharUnits::One());
+ }
+ }
----------------
Fznamznon wrote:
```suggestion
if (AllowConstexprUnknown && !Result)
Result = new APValue(Base, APValue::ConstexprUnknown{}, CharUnits::One());
```
https://github.com/llvm/llvm-project/pull/95474
More information about the cfe-commits
mailing list