[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
Wed Oct 22 16:59:47 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) {}
+
+CXXReflectExpr::CXXReflectExpr(EmptyShell Empty)
+    : Expr(CXXReflectExprClass, Empty) {}
+
+CXXReflectExpr *CXXReflectExpr::Create(ASTContext &C,
+                                       SourceLocation OperatorLoc,
+                                       SourceLocation OperandLoc,
+                                       QualType Operand) {
+  CXXReflectExpr *E = new (C) CXXReflectExpr(C, C.VoidTy, Operand);
+  E->setOperatorLoc(OperatorLoc);
+  E->setOperandRange(OperandLoc);
+  return E;
+}
+
+CXXReflectExpr *CXXReflectExpr::Create(ASTContext &C,
+                                       SourceLocation OperatorLoc,
+                                       SourceLocation OperandLoc,
+                                       Decl *Operand) {
+  bool IsNamespace = isa<TranslationUnitDecl>(Operand);
----------------
katzdm wrote:

Just confirming that reflection does preserve namespace aliases (though only the "top level" ones - applying `std::meta::dealias` recursively unwraps to the underlying entity, i.e., the namespace).

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


More information about the cfe-commits mailing list