From d58cb7b41ac1912fafcc3a52424c30b94905686d 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) llvm-svn: 219065 --- 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;