[clang] Fix MSVC warning in CompilerInvocation.cpp (PR #152809)

Daniel Paoliello via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 8 15:41:12 PDT 2025


https://github.com/dpaoliello created https://github.com/llvm/llvm-project/pull/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.

>From 9e23dfbbd651fc2b28c56272db002ddd8eb774b5 Mon Sep 17 00:00:00 2001
From: Daniel Paoliello <danpao at microsoft.com>
Date: Fri, 8 Aug 2025 15:37:17 -0700
Subject: [PATCH] Fix MSVC warning in CompilerInvocation.cpp

---
 clang/lib/Frontend/CompilerInvocation.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index ccc3154d20968..d9260e12cec3f 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -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<unsigned, unsigned>(Major_, Minor_)) \
     Opts.setClangABICompat(LangOptions::ClangABI::Ver##Major_##_##Minor_);     \
   else
 #define ABI_VER_MAJOR(Major_)                                                  \



More information about the cfe-commits mailing list