Skip to content

Commit d11e9a6

Browse files
committed
Don't use CLANG_VERSION_MAJOR to check that the value passed to
-fclang-abi-compat= is valid Use LLVM_VERSION_MAJOR instead as the maximum allowed value. This change is needed to fix regression tests that fail when vendors set CLANG_VERSION_MAJOR to a value that is lower than LLVM_VERSION_MAJOR when building the compiler. For example, clang/test/CodeGenCXX/mangle-concept.cpp fails with the following error if -DCLANG_VERSION_MAJOR=17 is passed to cmake: invalid value '19' in '-fclang-abi-compat=19'
1 parent db408ac commit d11e9a6

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

clang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ if(NOT DEFINED CLANG_VERSION_SUFFIX)
331331
set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
332332
endif()
333333
set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}")
334+
set(MAX_CLANG_ABI_COMPAT_VERSION "${LLVM_VERSION_MAJOR}")
334335
message(STATUS "Clang version: ${CLANG_VERSION}")
335336

336337
# Configure the Version.inc file.

clang/include/clang/Basic/Version.inc.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
#define CLANG_VERSION_MAJOR_STRING "@CLANG_VERSION_MAJOR@"
55
#define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
66
#define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@
7+
#define MAX_CLANG_ABI_COMPAT_VERSION @MAX_CLANG_ABI_COMPAT_VERSION@

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4387,7 +4387,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
43874387
// y or y.0 (4 <= y <= current version).
43884388
if (!VerParts.first.starts_with("0") &&
43894389
!VerParts.first.getAsInteger(10, Major) && 3 <= Major &&
4390-
Major <= CLANG_VERSION_MAJOR &&
4390+
Major <= MAX_CLANG_ABI_COMPAT_VERSION &&
43914391
(Major == 3
43924392
? VerParts.second.size() == 1 &&
43934393
!VerParts.second.getAsInteger(10, Minor)

0 commit comments

Comments
 (0)