[clang] [clang]: reflection operator parsing for global namespace and primitive types (PR #164692)

Daniel M. Katz via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 23 08:18:17 PDT 2025


================
@@ -1939,6 +1939,43 @@ TypeTraitExpr *TypeTraitExpr::CreateDeserialized(const ASTContext &C,
   return new (Mem) TypeTraitExpr(EmptyShell(), IsStoredAsBool);
 }
 
+CXXReflectExpr::CXXReflectExpr(const ASTContext &C, QualType T, QualType Ty)
+    : Expr(CXXReflectExprClass, T, VK_PRValue, OK_Ordinary) {}
+
+CXXReflectExpr::CXXReflectExpr(const ASTContext &C, QualType T, Decl *Arg,
+                               bool IsNamespace)
+    : Expr(CXXReflectExprClass, T, VK_PRValue, OK_Ordinary) {}
----------------
katzdm wrote:

Yeah, so maybe just:
- the `ReflectionData` can be (`void *`, `Depth`, `QualType`);
- that `void *` can be an `APValue *` when it reflects a value or object;
- the pointed-to `APValue` is allocated in some manner by `EvalInfo` such that its memory can be reclaimed during/after constant evaluation; and
- the pointed-to `APValue` is only persisted to the `ASTContext` if it's needed for the representation of the result of the constant evaluation. 

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


More information about the cfe-commits mailing list