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

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 23 08:06:27 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) {}
----------------
Sirraide wrote:

> there's also a `QualType` because we otherwise can't distinguish between e.g., "a reflection of an int value" and "a reflection of a short value"

Yeah, that’s a good point; with that approach the type has to be stored outside the union, even if it is unused most of the time (since the vast majority of `APValue`s are not reflexions). 

> Assuming there's no clever way around needing that

I don’t think there is; we can’t rely on e.g. bit width because we wouldn’t be able to distinguish between e.g. `signed char`/`unsigned char` and `char` or `_BitInt(128)` and `__int128_t`.

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


More information about the cfe-commits mailing list