[llvm] r224044 - Silence static analyzer warnings in LLVMSupport.
Michael Ilseman
milseman at apple.com
Thu Dec 11 11:46:38 PST 2014
Author: milseman
Date: Thu Dec 11 13:46:38 2014
New Revision: 224044
URL: http://llvm.org/viewvc/llvm-project?rev=224044&view=rev
Log:
Silence static analyzer warnings in LLVMSupport.
The static analyzer catches a few potential bugs in LLVMSupport. Add
in asserts to silence the warnings.
Modified:
llvm/trunk/lib/Support/CommandLine.cpp
llvm/trunk/lib/Support/ScaledNumber.cpp
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=224044&r1=224043&r2=224044&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Thu Dec 11 13:46:38 2014
@@ -323,6 +323,7 @@ static inline bool ProvideOption(Option
if (i+1 >= argc)
return Handler->error("requires a value!");
// Steal the next argument, like for '-o filename'
+ assert(argv && "null check");
Value = argv[++i];
}
break;
@@ -356,6 +357,7 @@ static inline bool ProvideOption(Option
while (NumAdditionalVals > 0) {
if (i+1 >= argc)
return Handler->error("not enough values!");
+ assert(argv && "null check");
Value = argv[++i];
if (CommaSeparateAndAddOccurrence(Handler, i, ArgName, Value, MultiArg))
Modified: llvm/trunk/lib/Support/ScaledNumber.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ScaledNumber.cpp?rev=224044&r1=224043&r2=224044&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ScaledNumber.cpp (original)
+++ llvm/trunk/lib/Support/ScaledNumber.cpp Thu Dec 11 13:46:38 2014
@@ -169,6 +169,8 @@ static std::string toStringAPFloat(uint6
int Shift = 63 - (NewE - E);
assert(Shift <= LeadingZeros);
assert(Shift == LeadingZeros || NewE == ScaledNumbers::MaxScale);
+ assert((Shift & (1u << std::numeric_limits<int>::digits)) == 0 &&
+ "undefined behavior");
D <<= Shift;
E = NewE;
More information about the llvm-commits
mailing list