With trunk r219051 Visual C++ warns: C:\llvm-clean\include\llvm/ADT/StringRef.h(351): warning C4805: '!=' : unsafe mix of type 'bool' and type 'unsigned __int64' in operation (..\..\..\lib\Analysis\ModuleDebugInfoPrinter.cpp) [C:\llvm-clean\msvc\lib\Analysis\LLVMAnalysis.vcxproj] C:\llvm-clean\include\llvm/IR/DebugInfo.h(200) : see reference to function template instantiation 'bool llvm::Stri ngRef::getAsInteger<T>(unsigned int,T &) const' being compiled with [ T=bool ] C:\llvm-clean\include\llvm/IR/DebugInfo.h(554) : see reference to function template instantiation 'T llvm::DIDescr iptor::getHeaderFieldAs<bool>(unsigned int) const' being compiled with [ T=bool ] the warning may have merit, when getHeaderFieldAs<bool> instantiates getAsInteger with T=bool ,the comparison logic static_cast<T>(ULLVal) != ULLVal) which for integers checks if the ULLVal fits in a T sized integer will work somewhat differently for a bool. It will check if ULLVal was 0 or 1 and if not return an error code. This in incosistent with the usual C++ assumption that any non-zero is true.
This looks to me like it's from my r219010. Am I right that this warning is coming from `StringRef::getAsInteger<bool>()`? If so, the behaviour I expect is: `"0"` gives `false`, `"1"` gives `true`, anything else is an error. From your description, it sounds like this is what we're getting -- good. Any idea how to suppress the warning?
Maybe casting it back to long long so the comparison would be between two long longs: if (getAsUnsignedInteger(*this, Radix, ULLVal) || static_cast<long long>(static_cast<T>(ULLVal)) != ULLVal) I'm building and testing this first.
Yup, that should work. You should probably use `unsigned long long`, since you're in the unsigned code there. Also, add a comment explaining that this is to hide an MSVC warning on `bool`, or someone is likely to remove the redundant explicit cast in the future.
Fixed in r219065.