Skip to content

Commit a5f6dcf

Browse files
committed
Add ABI_VER_LATEST macro
1 parent 8881837 commit a5f6dcf

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

clang/include/clang/Basic/ABIVersions.def

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@
1212
//
1313
/// @file ABIVersions.def
1414
///
15-
/// In this file, each of the Clang ABI Versions except "latest" is enumerated
16-
/// ABI_VER_MAJOR_MINOR, or ABI_VER_MAJOR macro.
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.
1717
///
1818
/// ABI_VER_MAJOR is used when the minor version is 0 or can be omitted.
1919
///
2020
/// The first argument of ABI_VER_MAJOR_MINOR and ABI_VER_MAJOR is the major
2121
/// version.
2222
///
2323
/// 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`.
2426

25-
#if defined(ABI_VER_MAJOR_MINOR) != defined(ABI_VER_MAJOR)
26-
# error ABI_VER_MAJOR_MINOR and ABI_VER_MAJOR should be defined simultaneously
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
2730
#endif
2831

2932
#ifndef ABI_VER_MAJOR_MINOR
@@ -34,6 +37,10 @@
3437
# define ABI_VER_MAJOR(Major)
3538
#endif
3639

40+
#ifndef ABI_VER_LATEST
41+
# define ABI_VER_LATEST(Latest)
42+
#endif
43+
3744
/// Attempt to be ABI-compatible with code generated by Clang 3.8.x
3845
/// (SVN r257626). This causes <1 x long long> to be passed in an integer
3946
/// register instead of an SSE register on x64_64.
@@ -121,7 +128,8 @@ ABI_VER_MAJOR(19)
121128
ABI_VER_MAJOR(20)
122129

123130
/// Conform to the underlying platform's C and C++ ABIs as closely as we can.
124-
// (latest)
131+
ABI_VER_LATEST(Latest)
125132

126133
#undef ABI_VER_MAJOR_MINOR
127134
#undef ABI_VER_MAJOR
135+
#undef ABI_VER_LATEST

clang/include/clang/Basic/LangOptions.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,8 @@ class LangOptionsBase {
188188
enum class ClangABI {
189189
#define ABI_VER_MAJOR_MINOR(Major, Minor) Ver##Major##_##Minor,
190190
#define ABI_VER_MAJOR(Major) Ver##Major,
191+
#define ABI_VER_LATEST(Latest) Latest
191192
#include "clang/Basic/ABIVersions.def"
192-
193-
Latest
194193
};
195194

196195
enum class CoreFoundationABI {

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3944,10 +3944,10 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
39443944
case LangOptions::ClangABI::Ver##Major: \
39453945
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, #Major ".0"); \
39463946
break;
3947-
#include "clang/Basic/ABIVersions.def"
3948-
3949-
case LangOptions::ClangABI::Latest:
3947+
#define ABI_VER_LATEST(Latest) \
3948+
case LangOptions::ClangABI::Latest: \
39503949
break;
3950+
#include "clang/Basic/ABIVersions.def"
39513951
}
39523952

39533953
if (Opts.getSignReturnAddressScope() ==
@@ -4461,8 +4461,10 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
44614461
if (Major <= Major_) \
44624462
Opts.setClangABICompat(LangOptions::ClangABI::Ver##Major_); \
44634463
else
4464+
#define ABI_VER_LATEST(Latest) \
4465+
{ /* Equivalent to latest version - do nothing */ \
4466+
}
44644467
#include "clang/Basic/ABIVersions.def"
4465-
{} // sub-statement of the last else branch
44664468
} else if (Ver != "latest") {
44674469
Diags.Report(diag::err_drv_invalid_value)
44684470
<< A->getAsString(Args) << A->getValue();

0 commit comments

Comments
 (0)