Skip to content

Commit 96d7905

Browse files
author
git apple-llvm automerger
committed
Merge commit '109040acec00' from llvm.org/main into next
2 parents c13219e + 109040a commit 96d7905

File tree

3 files changed

+160
-153
lines changed

3 files changed

+160
-153
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
//===--- ABIVersions.def - Clang ABI Versions Database ----------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file enumerates Clang ABI versions.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
/// @file ABIVersions.def
14+
///
15+
/// In this file, each of the Clang ABI Versions is enumerated
16+
/// ABI_VER_MAJOR_MINOR, ABI_VER_MAJOR, or ABI_VER_LATEST macro.
17+
///
18+
/// ABI_VER_MAJOR is used when the minor version is 0 or can be omitted.
19+
///
20+
/// The first argument of ABI_VER_MAJOR_MINOR and ABI_VER_MAJOR is the major
21+
/// version.
22+
///
23+
/// The second argument of ABI_VER_MAJOR_MINOR is the minor version.
24+
///
25+
/// The first argument of ABI_VER_LATEST is an identifier `Latest`.
26+
27+
#if defined(ABI_VER_MAJOR_MINOR) != defined(ABI_VER_MAJOR) || \
28+
defined(ABI_VER_MAJOR) != defined(ABI_VER_LATEST)
29+
# error ABI_VER_MAJOR_MINOR, ABI_VER_MAJOR and ABI_VER_LATEST should be defined simultaneously
30+
#endif
31+
32+
#ifndef ABI_VER_MAJOR_MINOR
33+
# define ABI_VER_MAJOR_MINOR(Major, Minor)
34+
#endif
35+
36+
#ifndef ABI_VER_MAJOR
37+
# define ABI_VER_MAJOR(Major)
38+
#endif
39+
40+
#ifndef ABI_VER_LATEST
41+
# define ABI_VER_LATEST(Latest)
42+
#endif
43+
44+
/// Attempt to be ABI-compatible with code generated by Clang 3.8.x
45+
/// (SVN r257626). This causes <1 x long long> to be passed in an integer
46+
/// register instead of an SSE register on x64_64.
47+
ABI_VER_MAJOR_MINOR(3, 8)
48+
49+
/// Attempt to be ABI-compatible with code generated by Clang 4.0.x
50+
/// (SVN r291814). This causes move operations to be ignored when determining
51+
/// whether a class type can be passed or returned directly.
52+
ABI_VER_MAJOR(4)
53+
54+
/// Attempt to be ABI-compatible with code generated by Clang 6.0.x
55+
/// (SVN r321711). This causes determination of whether a type is
56+
/// standard-layout to ignore collisions between empty base classes and between
57+
/// base classes and member subobjects, which affects whether we reuse base
58+
/// class tail padding in some ABIs.
59+
ABI_VER_MAJOR(6)
60+
61+
/// Attempt to be ABI-compatible with code generated by Clang 7.0.x
62+
/// (SVN r338536). This causes alignof (C++) and _Alignof (C11) to be compatible
63+
/// with __alignof (i.e., return the preferred alignment) rather than returning
64+
/// the required alignment.
65+
ABI_VER_MAJOR(7)
66+
67+
/// Attempt to be ABI-compatible with code generated by Clang 9.0.x
68+
/// (SVN r351319). This causes vectors of __int128 to be passed in memory
69+
/// instead of passing in multiple scalar registers on x86_64 on Linux and
70+
/// NetBSD.
71+
ABI_VER_MAJOR(9)
72+
73+
/// Attempt to be ABI-compatible with code generated by Clang 11.0.x
74+
/// (git 2e10b7a39b93). This causes clang to pass unions with a 256-bit vector
75+
/// member on the stack instead of using registers, to not properly mangle
76+
/// substitutions for template names in some cases, and to mangle declaration
77+
/// template arguments without a cast to the parameter type even when that can
78+
/// lead to mangling collisions.
79+
ABI_VER_MAJOR(11)
80+
81+
/// Attempt to be ABI-compatible with code generated by Clang 12.0.x
82+
/// (git 8e464dd76bef). This causes clang to mangle lambdas within global-scope
83+
/// inline variables incorrectly.
84+
ABI_VER_MAJOR(12)
85+
86+
/// Attempt to be ABI-compatible with code generated by Clang 14.0.x.
87+
/// This causes clang to:
88+
/// - mangle dependent nested names incorrectly.
89+
/// - make trivial only those defaulted copy constructors with a
90+
/// parameter-type-list equivalent to the parameter-type-list of an implicit
91+
/// declaration.
92+
ABI_VER_MAJOR(14)
93+
94+
/// Attempt to be ABI-compatible with code generated by Clang 15.0.x.
95+
/// This causes clang to:
96+
/// - Reverse the implementation for CWG692, CWG1395 and CWG1432.
97+
/// - pack non-POD members of packed structs.
98+
/// - consider classes with defaulted special member functions non-pod.
99+
ABI_VER_MAJOR(15)
100+
101+
/// Attempt to be ABI-compatible with code generated by Clang 17.0.x.
102+
/// This causes clang to revert some fixes to its implementation of the Itanium
103+
/// name mangling scheme, with the consequence that overloaded function
104+
/// templates are mangled the same if they differ only by:
105+
/// - constraints
106+
/// - whether a non-type template parameter has a deduced type
107+
/// - the parameter list of a template template parameter
108+
ABI_VER_MAJOR(17)
109+
110+
/// Attempt to be ABI-compatible with code generated by Clang 18.0.x.
111+
/// This causes clang to revert some fixes to the mangling of lambdas in the
112+
/// initializers of members of local classes.
113+
ABI_VER_MAJOR(18)
114+
115+
/// Attempt to be ABI-compatible with code generated by Clang 19.0.x.
116+
/// This causes clang to:
117+
/// - Incorrectly mangle the 'base type' substitutions of the CXX construction
118+
/// vtable because it hasn't added 'type' as a substitution.
119+
/// - Skip mangling enclosing class templates of member-like friend function
120+
/// templates.
121+
/// - Ignore empty struct arguments in C++ mode for ARM, instead of passing
122+
/// them as if they had a size of 1 byte.
123+
ABI_VER_MAJOR(19)
124+
125+
/// Attempt to be ABI-compatible with code generated by Clang 20.0.x.
126+
/// This causes clang to:
127+
/// - Incorrectly return C++ records in AVX registers on x86_64.
128+
ABI_VER_MAJOR(20)
129+
130+
/// Conform to the underlying platform's C and C++ ABIs as closely as we can.
131+
ABI_VER_LATEST(Latest)
132+
133+
#undef ABI_VER_MAJOR_MINOR
134+
#undef ABI_VER_MAJOR
135+
#undef ABI_VER_LATEST

clang/include/clang/Basic/LangOptions.h

Lines changed: 4 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -188,95 +188,10 @@ class LangOptionsBase {
188188

189189
/// Clang versions with different platform ABI conformance.
190190
enum class ClangABI {
191-
/// Attempt to be ABI-compatible with code generated by Clang 3.8.x
192-
/// (SVN r257626). This causes <1 x long long> to be passed in an
193-
/// integer register instead of an SSE register on x64_64.
194-
Ver3_8,
195-
196-
/// Attempt to be ABI-compatible with code generated by Clang 4.0.x
197-
/// (SVN r291814). This causes move operations to be ignored when
198-
/// determining whether a class type can be passed or returned directly.
199-
Ver4,
200-
201-
/// Attempt to be ABI-compatible with code generated by Clang 6.0.x
202-
/// (SVN r321711). This causes determination of whether a type is
203-
/// standard-layout to ignore collisions between empty base classes
204-
/// and between base classes and member subobjects, which affects
205-
/// whether we reuse base class tail padding in some ABIs.
206-
Ver6,
207-
208-
/// Attempt to be ABI-compatible with code generated by Clang 7.0.x
209-
/// (SVN r338536). This causes alignof (C++) and _Alignof (C11) to be
210-
/// compatible with __alignof (i.e., return the preferred alignment)
211-
/// rather than returning the required alignment.
212-
Ver7,
213-
214-
/// Attempt to be ABI-compatible with code generated by Clang 9.0.x
215-
/// (SVN r351319). This causes vectors of __int128 to be passed in memory
216-
/// instead of passing in multiple scalar registers on x86_64 on Linux and
217-
/// NetBSD.
218-
Ver9,
219-
220-
/// Attempt to be ABI-compatible with code generated by Clang 11.0.x
221-
/// (git 2e10b7a39b93). This causes clang to pass unions with a 256-bit
222-
/// vector member on the stack instead of using registers, to not properly
223-
/// mangle substitutions for template names in some cases, and to mangle
224-
/// declaration template arguments without a cast to the parameter type
225-
/// even when that can lead to mangling collisions.
226-
Ver11,
227-
228-
/// Attempt to be ABI-compatible with code generated by Clang 12.0.x
229-
/// (git 8e464dd76bef). This causes clang to mangle lambdas within
230-
/// global-scope inline variables incorrectly.
231-
Ver12,
232-
233-
/// Attempt to be ABI-compatible with code generated by Clang 14.0.x.
234-
/// This causes clang to:
235-
/// - mangle dependent nested names incorrectly.
236-
/// - make trivial only those defaulted copy constructors with a
237-
/// parameter-type-list equivalent to the parameter-type-list of an
238-
/// implicit declaration.
239-
Ver14,
240-
241-
/// Attempt to be ABI-compatible with code generated by Clang 15.0.x.
242-
/// This causes clang to:
243-
/// - Reverse the implementation for DR692, DR1395 and DR1432.
244-
/// - pack non-POD members of packed structs.
245-
/// - consider classes with defaulted special member functions non-pod.
246-
Ver15,
247-
248-
/// Attempt to be ABI-compatible with code generated by Clang 17.0.x.
249-
/// This causes clang to revert some fixes to its implementation of the
250-
/// Itanium name mangling scheme, with the consequence that overloaded
251-
/// function templates are mangled the same if they differ only by:
252-
/// - constraints
253-
/// - whether a non-type template parameter has a deduced type
254-
/// - the parameter list of a template template parameter
255-
Ver17,
256-
257-
/// Attempt to be ABI-compatible with code generated by Clang 18.0.x.
258-
/// This causes clang to revert some fixes to the mangling of lambdas
259-
/// in the initializers of members of local classes.
260-
Ver18,
261-
262-
/// Attempt to be ABI-compatible with code generated by Clang 19.0.x.
263-
/// This causes clang to:
264-
/// - Incorrectly mangle the 'base type' substitutions of the CXX
265-
/// construction vtable because it hasn't added 'type' as a substitution.
266-
/// - Skip mangling enclosing class templates of member-like friend
267-
/// function templates.
268-
/// - Ignore empty struct arguments in C++ mode for ARM, instead of
269-
/// passing them as if they had a size of 1 byte.
270-
Ver19,
271-
272-
/// Attempt to be ABI-compatible with code generated by Clang 20.0.x.
273-
/// This causes clang to:
274-
/// - Incorrectly return C++ records in AVX registers on x86_64.
275-
Ver20,
276-
277-
/// Conform to the underlying platform's C and C++ ABIs as closely
278-
/// as we can.
279-
Latest
191+
#define ABI_VER_MAJOR_MINOR(Major, Minor) Ver##Major##_##Minor,
192+
#define ABI_VER_MAJOR(Major) Ver##Major,
193+
#define ABI_VER_LATEST(Latest) Latest
194+
#include "clang/Basic/ABIVersions.def"
280195
};
281196

282197
enum class CoreFoundationABI {

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 21 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4273,47 +4273,18 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
42734273
GenerateArg(Consumer, OPT_fsanitize_ignorelist_EQ, F);
42744274

42754275
switch (Opts.getClangABICompat()) {
4276-
case LangOptions::ClangABI::Ver3_8:
4277-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "3.8");
4276+
#define ABI_VER_MAJOR_MINOR(Major, Minor) \
4277+
case LangOptions::ClangABI::Ver##Major##_##Minor: \
4278+
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, #Major "." #Minor); \
42784279
break;
4279-
case LangOptions::ClangABI::Ver4:
4280-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "4.0");
4280+
#define ABI_VER_MAJOR(Major) \
4281+
case LangOptions::ClangABI::Ver##Major: \
4282+
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, #Major ".0"); \
42814283
break;
4282-
case LangOptions::ClangABI::Ver6:
4283-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "6.0");
4284-
break;
4285-
case LangOptions::ClangABI::Ver7:
4286-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "7.0");
4287-
break;
4288-
case LangOptions::ClangABI::Ver9:
4289-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "9.0");
4290-
break;
4291-
case LangOptions::ClangABI::Ver11:
4292-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "11.0");
4293-
break;
4294-
case LangOptions::ClangABI::Ver12:
4295-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "12.0");
4296-
break;
4297-
case LangOptions::ClangABI::Ver14:
4298-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "14.0");
4299-
break;
4300-
case LangOptions::ClangABI::Ver15:
4301-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "15.0");
4302-
break;
4303-
case LangOptions::ClangABI::Ver17:
4304-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "17.0");
4305-
break;
4306-
case LangOptions::ClangABI::Ver18:
4307-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "18.0");
4308-
break;
4309-
case LangOptions::ClangABI::Ver19:
4310-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "19.0");
4311-
break;
4312-
case LangOptions::ClangABI::Ver20:
4313-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "20.0");
4314-
break;
4315-
case LangOptions::ClangABI::Latest:
4284+
#define ABI_VER_LATEST(Latest) \
4285+
case LangOptions::ClangABI::Latest: \
43164286
break;
4287+
#include "clang/Basic/ABIVersions.def"
43174288
}
43184289

43194290
if (Opts.getSignReturnAddressScope() ==
@@ -4927,32 +4898,18 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
49274898
!VerParts.second.getAsInteger(10, Minor)
49284899
: VerParts.first.size() == Ver.size() || VerParts.second == "0")) {
49294900
// Got a valid version number.
4930-
if (Major == 3 && Minor <= 8)
4931-
Opts.setClangABICompat(LangOptions::ClangABI::Ver3_8);
4932-
else if (Major <= 4)
4933-
Opts.setClangABICompat(LangOptions::ClangABI::Ver4);
4934-
else if (Major <= 6)
4935-
Opts.setClangABICompat(LangOptions::ClangABI::Ver6);
4936-
else if (Major <= 7)
4937-
Opts.setClangABICompat(LangOptions::ClangABI::Ver7);
4938-
else if (Major <= 9)
4939-
Opts.setClangABICompat(LangOptions::ClangABI::Ver9);
4940-
else if (Major <= 11)
4941-
Opts.setClangABICompat(LangOptions::ClangABI::Ver11);
4942-
else if (Major <= 12)
4943-
Opts.setClangABICompat(LangOptions::ClangABI::Ver12);
4944-
else if (Major <= 14)
4945-
Opts.setClangABICompat(LangOptions::ClangABI::Ver14);
4946-
else if (Major <= 15)
4947-
Opts.setClangABICompat(LangOptions::ClangABI::Ver15);
4948-
else if (Major <= 17)
4949-
Opts.setClangABICompat(LangOptions::ClangABI::Ver17);
4950-
else if (Major <= 18)
4951-
Opts.setClangABICompat(LangOptions::ClangABI::Ver18);
4952-
else if (Major <= 19)
4953-
Opts.setClangABICompat(LangOptions::ClangABI::Ver19);
4954-
else if (Major <= 20)
4955-
Opts.setClangABICompat(LangOptions::ClangABI::Ver20);
4901+
#define ABI_VER_MAJOR_MINOR(Major_, Minor_) \
4902+
if (std::tie(Major, Minor) <= std::tuple(Major_, Minor_)) \
4903+
Opts.setClangABICompat(LangOptions::ClangABI::Ver##Major_##_##Minor_); \
4904+
else
4905+
#define ABI_VER_MAJOR(Major_) \
4906+
if (Major <= Major_) \
4907+
Opts.setClangABICompat(LangOptions::ClangABI::Ver##Major_); \
4908+
else
4909+
#define ABI_VER_LATEST(Latest) \
4910+
{ /* Equivalent to latest version - do nothing */ \
4911+
}
4912+
#include "clang/Basic/ABIVersions.def"
49564913
} else if (Ver != "latest") {
49574914
Diags.Report(diag::err_drv_invalid_value)
49584915
<< A->getAsString(Args) << A->getValue();

0 commit comments

Comments
 (0)