[llvm] 5bd8f48 - [FileCheck] Fix MSVC 'argument': truncation from 'int' to 'bool' warning.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 8 02:10:07 PDT 2023


Author: Simon Pilgrim
Date: 2023-08-08T10:05:24+01:00
New Revision: 5bd8f481c1613b864bde53c998a4fd74f4b7cd21

URL: https://github.com/llvm/llvm-project/commit/5bd8f481c1613b864bde53c998a4fd74f4b7cd21
DIFF: https://github.com/llvm/llvm-project/commit/5bd8f481c1613b864bde53c998a4fd74f4b7cd21.diff

LOG: [FileCheck] Fix MSVC 'argument': truncation from 'int' to 'bool' warning.

Ensure expectOperationValueResult performs the is_integral_v as constexpr to prevent MSVC getting confused between the mixture of integer / string constructors in the if-else.

Warning introduced in D150880

Added: 
    

Modified: 
    llvm/unittests/FileCheck/FileCheckTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/FileCheck/FileCheckTest.cpp b/llvm/unittests/FileCheck/FileCheckTest.cpp
index e93ee8de01302e..4b844a9ff86d15 100644
--- a/llvm/unittests/FileCheck/FileCheckTest.cpp
+++ b/llvm/unittests/FileCheck/FileCheckTest.cpp
@@ -395,10 +395,11 @@ static void expectOperationValueResult(binop_eval_t Operation, T1 LeftValue,
                                        T2 RightValue, TR ResultValue) {
   APInt LeftVal(LiteralsBitWidth, LeftValue, std::is_signed_v<T1>);
   APInt RightVal(LiteralsBitWidth, RightValue, std::is_signed_v<T2>);
-  APInt ResultVal =
-      std::is_integral_v<TR>
-          ? APInt(LiteralsBitWidth, ResultValue, std::is_signed_v<TR>)
-          : APInt(LiteralsBitWidth, ResultValue, /*Radix=*/10);
+  APInt ResultVal;
+  if constexpr (std::is_integral_v<TR>)
+    ResultVal = APInt(LiteralsBitWidth, ResultValue, std::is_signed_v<TR>);
+  else
+    ResultVal = APInt(LiteralsBitWidth, ResultValue, /*Radix=*/10);
   expectOperationValueResult(Operation, LeftVal, RightVal, ResultVal);
 }
 


        


More information about the llvm-commits mailing list