Skip to content

Commit 6092740

Browse files
authored
Don't use CLANG_VERSION_MAJOR to check that the value passed to -fclang-abi-compat= is valid (#123998)
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 d0052eb commit 6092740

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
@@ -4413,7 +4413,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
44134413
// y or y.0 (4 <= y <= current version).
44144414
if (!VerParts.first.starts_with("0") &&
44154415
!VerParts.first.getAsInteger(10, Major) && 3 <= Major &&
4416-
Major <= CLANG_VERSION_MAJOR &&
4416+
Major <= MAX_CLANG_ABI_COMPAT_VERSION &&
44174417
(Major == 3
44184418
? VerParts.second.size() == 1 &&
44194419
!VerParts.second.getAsInteger(10, Minor)

0 commit comments

Comments
 (0)