@@ -492,9 +492,22 @@ def TargetHasDLLImportExport : TargetSpec {
492492def TargetItaniumCXXABI : TargetSpec {
493493 let CustomCode = [{ Target.getCXXABI().isItaniumFamily() }];
494494}
495+
495496def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
496497 let CustomCode = [{ Target.getCXXABI().isMicrosoft() }];
497498}
499+
500+ // The target follows Microsoft record layout. Usually this happens in two
501+ // cases: 1. the target itself has Microsoft C++ ABI, e.g. x86_64 in MSVC
502+ // environment on Windows 2. an offloading target e.g. amdgcn or nvptx with
503+ // a host target in MSVC environment on Windows.
504+ def TargetMicrosoftRecordLayout : TargetArch<["x86", "x86_64", "arm", "thumb",
505+ "aarch64", "amdgcn", "nvptx",
506+ "nvptx64", "spirv", "spirv32",
507+ "spirv64"]> {
508+ let CustomCode = [{ Target.hasMicrosoftRecordLayout() }];
509+ }
510+
498511def TargetELF : TargetSpec {
499512 let ObjectFormats = ["ELF"];
500513}
@@ -1789,7 +1802,7 @@ def Destructor : InheritableAttr {
17891802 let Documentation = [CtorDtorDocs];
17901803}
17911804
1792- def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI > {
1805+ def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftRecordLayout > {
17931806 let Spellings = [Declspec<"empty_bases">];
17941807 let Subjects = SubjectList<[CXXRecord]>;
17951808 let Documentation = [EmptyBasesDocs];
@@ -2021,7 +2034,7 @@ def Restrict : InheritableAttr {
20212034 let Documentation = [RestrictDocs];
20222035}
20232036
2024- def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI > {
2037+ def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftRecordLayout > {
20252038 let Spellings = [Declspec<"layout_version">];
20262039 let Args = [UnsignedArgument<"Version">];
20272040 let Subjects = SubjectList<[CXXRecord]>;
@@ -2239,7 +2252,7 @@ def NoUniqueAddress : InheritableAttr {
22392252 let Spellings = [CXX11<"", "no_unique_address", 201803>, CXX11<"msvc", "no_unique_address", 201803>];
22402253 let TargetSpecificSpellings = [
22412254 TargetSpecificSpelling<TargetItaniumCXXABI, [CXX11<"", "no_unique_address", 201803>]>,
2242- TargetSpecificSpelling<TargetMicrosoftCXXABI , [CXX11<"msvc", "no_unique_address", 201803>]>,
2255+ TargetSpecificSpelling<TargetMicrosoftRecordLayout , [CXX11<"msvc", "no_unique_address", 201803>]>,
22432256 ];
22442257 let Documentation = [NoUniqueAddressDocs];
22452258}
0 commit comments