================
@@ -2951,6 +2951,33 @@ VarDecl::setInstantiationOfStaticDataMember(VarDecl *VD,
getASTContext().setInstantiatedFromStaticDataMember(this, VD, TSK);
}
+void VarDecl::assignAddressSpace(const ASTContext &Ctxt, LangAS AS) {
+ QualType Type = getType();
+ if (Type.hasAddressSpace())
+ return;
+ if (Type->isDependentType())
+ return;
+ if (Type->isSamplerT() || Type->isVoidType())
+ return;
+ assert(isa<ParmVarDecl>(this) || isa<ImplicitParamDecl>(this)
+ ? !Type->isArrayType()
+ : !isa<DecayedType>(Type));
+ Type = Ctxt.getAddrSpaceQualType(Type, AS);
+ // Apply any qualifiers (including address space) from the array type to
+ // the element type. This implements C99 6.7.3p8: "If the specification of
+ // an array type includes any type qualifiers, the element type is so
+ // qualified, not the array type."
+ if (Type->isArrayType())
+ Type = QualType(Ctxt.getAsArrayType(Type), 0);
+ setType(Type);
+}
+
+void VarDecl::deduceParmAddressSpace(const ASTContext &Ctxt) {
+ assert(isa<ParmVarDecl>(this) || isa<ImplicitParamDecl>(this));
+ if (Ctxt.getLangOpts().OpenCL)
+ assignAddressSpace(Ctxt, LangAS::opencl_private);
----------------
arsenm wrote:
Should this also depend on not having generic address space
https://github.com/llvm/llvm-project/pull/184264
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits