Silence static analyzer warnings in LLVMSupport.
The static analyzer catches a few potential bugs in LLVMSupport. Add
in asserts to silence the warnings.
llvm-svn: 224044
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 985c877..7b06219 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -323,6 +323,7 @@
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 @@
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))
diff --git a/llvm/lib/Support/ScaledNumber.cpp b/llvm/lib/Support/ScaledNumber.cpp
index fc6d4e7..725f464 100644
--- a/llvm/lib/Support/ScaledNumber.cpp
+++ b/llvm/lib/Support/ScaledNumber.cpp
@@ -169,6 +169,8 @@
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;