[clang] 59f31d4 - Fix MSVC warning in CompilerInvocation.cpp (#152809)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 10 11:19:15 PDT 2025
Author: Daniel Paoliello
Date: 2025-08-10T11:19:12-07:00
New Revision: 59f31d4e8df8cc35c816c05f2c653ca29e9a276e
URL: https://github.com/llvm/llvm-project/commit/59f31d4e8df8cc35c816c05f2c653ca29e9a276e
DIFF: https://github.com/llvm/llvm-project/commit/59f31d4e8df8cc35c816c05f2c653ca29e9a276e.diff
LOG: Fix MSVC warning in CompilerInvocation.cpp (#152809)
Building Clang using MSVC was resulting in the following warning:
```
tuple(791): warning C4018: '<': signed/unsigned mismatch
```
I traced this to CompilerInvocation.cpp where it was creating a
`std::tuple` to compare version numbers.
This change adds an explicit type for the `tuple` created from the
version macros to match the type of the variables, and uses the `tuple`
constructor instead of `tie` since the integers are smaller than a
reference to the integers.
Added:
Modified:
clang/lib/Frontend/CompilerInvocation.cpp
Removed:
################################################################################
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index ccc3154d20968..2ea3ed759ff42 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4441,7 +4441,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
StringRef Ver = A->getValue();
std::pair<StringRef, StringRef> VerParts = Ver.split('.');
- unsigned Major, Minor = 0;
+ int Major, Minor = 0;
// Check the version number is valid: either 3.x (0 <= x <= 9) or
// y or y.0 (4 <= y <= current version).
@@ -4454,7 +4454,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
: VerParts.first.size() == Ver.size() || VerParts.second == "0")) {
// Got a valid version number.
#define ABI_VER_MAJOR_MINOR(Major_, Minor_) \
- if (std::tie(Major, Minor) <= std::tuple(Major_, Minor_)) \
+ if (std::tuple(Major, Minor) <= std::tuple(Major_, Minor_)) \
Opts.setClangABICompat(LangOptions::ClangABI::Ver##Major_##_##Minor_); \
else
#define ABI_VER_MAJOR(Major_) \
More information about the cfe-commits
mailing list