From 30d433dcc2c5a766d2c8973075bb66b4b830cb81 Mon Sep 17 00:00:00 2001 From: Yaron Keren Date: Sat, 4 Oct 2014 19:58:30 +0000 Subject: [PATCH] Solve Visual C++ warning C4805 on getAsInteger. Fix http://llvm.org/PR21158 by adding a cast to unsigned long long, so the comparison would be between two unsigned long longs instead of bool and unsigned long long. if (getAsUnsignedInteger(*this, Radix, ULLVal) || static_cast(static_cast(ULLVal)) != ULLVal) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219065 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/StringRef.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index f1861c8f92b..778fa10a32c 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -347,8 +347,11 @@ namespace llvm { typename std::enable_if::is_signed, bool>::type getAsInteger(unsigned Radix, T &Result) const { unsigned long long ULLVal; + // The additional cast to unsigned long long is required to avoid the + // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type + // 'unsigned __int64' when instantiating getAsInteger with T = bool. if (getAsUnsignedInteger(*this, Radix, ULLVal) || - static_cast(ULLVal) != ULLVal) + static_cast(static_cast(ULLVal)) != ULLVal) return true; Result = ULLVal; return false; -- 2.34.1