[clang] [clang][SYCL] Add SYCL spelling for AS attributes (PR #200849)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 2 06:17:06 PDT 2026
================
@@ -312,3 +313,26 @@ void clang::takeAndConcatenateAttrs(ParsedAttributes &First,
if (Second.Range.getEnd().isValid())
First.Range.setEnd(Second.Range.getEnd());
}
+
+LangAS ParsedAttr::asLangAS() const {
+ switch (getParsedKind()) {
+ case ParsedAttr::AT_OffloadGlobalAddressSpace:
+ return OffloadGlobalAddressSpaceAttr::getLangAS(*this);
+ case ParsedAttr::AT_OffloadGlobalDeviceAddressSpace:
+ return OffloadGlobalDeviceAddressSpaceAttr::getLangAS(*this);
+ case ParsedAttr::AT_OffloadGlobalHostAddressSpace:
+ return OffloadGlobalHostAddressSpaceAttr::getLangAS(*this);
+ case ParsedAttr::AT_OffloadLocalAddressSpace:
+ return OffloadLocalAddressSpaceAttr::getLangAS(*this);
+ case ParsedAttr::AT_OffloadPrivateAddressSpace:
+ return OffloadPrivateAddressSpaceAttr::getLangAS(*this);
+ case ParsedAttr::AT_OffloadConstantAddressSpace:
+ return OffloadConstantAddressSpaceAttr::getLangAS(*this);
+ case ParsedAttr::AT_OffloadGenericAddressSpace:
+ return OffloadGenericAddressSpaceAttr::getLangAS(*this);
+ case ParsedAttr::AT_HLSLGroupSharedAddressSpace:
+ return LangAS::hlsl_groupshared;
+ default:
+ return LangAS::Default;
+ }
+}
----------------
elizabethandrews wrote:
>>Once the attributes are limited to use in their appropriate modes, mapping becomes easier and mode based.
Prior to this PR, LangAS was mapped according to compilation mode, i.e. LangOpts. There were separate mapping functions selected based on LangOpts. My understanding was that you were not a fan of that and wanted mappings done based on spellings, which is why this change was made. I can revert to the old code AND also adding a spelling check if that is what you prefer.
https://github.com/llvm/llvm-project/pull/200849
More information about the cfe-commits
mailing list