[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 14 15:27:57 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());
+    }
+  }
----------------
shafik wrote:

Yes, this is a good point. When I started this a while ago I realized I needed to refactor this but I lost track of it since then.

I think I need to use `createTemporary(...)` or something along those lines.

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


More information about the cfe-commits mailing list