Skip to content

Commit 59f31d4

Browse files
authored
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.
1 parent 2b4b721 commit 59f31d4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4441,7 +4441,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
44414441

44424442
StringRef Ver = A->getValue();
44434443
std::pair<StringRef, StringRef> VerParts = Ver.split('.');
4444-
unsigned Major, Minor = 0;
4444+
int Major, Minor = 0;
44454445

44464446
// Check the version number is valid: either 3.x (0 <= x <= 9) or
44474447
// y or y.0 (4 <= y <= current version).
@@ -4454,7 +4454,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
44544454
: VerParts.first.size() == Ver.size() || VerParts.second == "0")) {
44554455
// Got a valid version number.
44564456
#define ABI_VER_MAJOR_MINOR(Major_, Minor_) \
4457-
if (std::tie(Major, Minor) <= std::tuple(Major_, Minor_)) \
4457+
if (std::tuple(Major, Minor) <= std::tuple(Major_, Minor_)) \
44584458
Opts.setClangABICompat(LangOptions::ClangABI::Ver##Major_##_##Minor_); \
44594459
else
44604460
#define ABI_VER_MAJOR(Major_) \

0 commit comments

Comments
 (0)