Skip to content

Don't use CLANG_VERSION_MAJOR to check that the value passed to -fclang-abi-compat= is valid #123998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ if(NOT DEFINED CLANG_VERSION_SUFFIX)
set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
endif()
set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}")
set(MAX_CLANG_ABI_COMPAT_VERSION "${LLVM_VERSION_MAJOR}")
message(STATUS "Clang version: ${CLANG_VERSION}")

# Configure the Version.inc file.
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/Version.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
#define CLANG_VERSION_MAJOR_STRING "@CLANG_VERSION_MAJOR@"
#define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
#define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@
#define MAX_CLANG_ABI_COMPAT_VERSION @MAX_CLANG_ABI_COMPAT_VERSION@
2 changes: 1 addition & 1 deletion clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4387,7 +4387,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
// y or y.0 (4 <= y <= current version).
if (!VerParts.first.starts_with("0") &&
!VerParts.first.getAsInteger(10, Major) && 3 <= Major &&
Major <= CLANG_VERSION_MAJOR &&
Major <= MAX_CLANG_ABI_COMPAT_VERSION &&
(Major == 3
? VerParts.second.size() == 1 &&
!VerParts.second.getAsInteger(10, Minor)
Expand Down
Loading