Changeset View
Changeset View
Standalone View
Standalone View
lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | bool pin(llvm::APSInt &Lower, llvm::APSInt &Upper) const { | ||||
APSIntType::RangeTestResultKind UpperTest = Type.testInRange(Upper, true); | APSIntType::RangeTestResultKind UpperTest = Type.testInRange(Upper, true); | ||||
switch (LowerTest) { | switch (LowerTest) { | ||||
case APSIntType::RTR_Below: | case APSIntType::RTR_Below: | ||||
switch (UpperTest) { | switch (UpperTest) { | ||||
case APSIntType::RTR_Below: | case APSIntType::RTR_Below: | ||||
// The entire range is outside the symbol's set of possible values. | // The entire range is outside the symbol's set of possible values. | ||||
// If this is a conventionally-ordered range, the state is infeasible. | // If this is a conventionally-ordered range, the state is infeasible. | ||||
if (Lower < Upper) | if (Lower <= Upper) | ||||
return false; | return false; | ||||
// However, if the range wraps around, it spans all possible values. | // However, if the range wraps around, it spans all possible values. | ||||
Lower = Type.getMinValue(); | Lower = Type.getMinValue(); | ||||
Upper = Type.getMaxValue(); | Upper = Type.getMaxValue(); | ||||
break; | break; | ||||
case APSIntType::RTR_Within: | case APSIntType::RTR_Within: | ||||
// The range starts below what's possible but ends within it. Pin. | // The range starts below what's possible but ends within it. Pin. | ||||
Show All 34 Lines | case APSIntType::RTR_Above: | ||||
case APSIntType::RTR_Within: | case APSIntType::RTR_Within: | ||||
// The range starts above what's possible but ends within it (wrap). | // The range starts above what's possible but ends within it (wrap). | ||||
Lower = Type.getMinValue(); | Lower = Type.getMinValue(); | ||||
Type.apply(Upper); | Type.apply(Upper); | ||||
break; | break; | ||||
case APSIntType::RTR_Above: | case APSIntType::RTR_Above: | ||||
// The entire range is outside the symbol's set of possible values. | // The entire range is outside the symbol's set of possible values. | ||||
// If this is a conventionally-ordered range, the state is infeasible. | // If this is a conventionally-ordered range, the state is infeasible. | ||||
if (Lower < Upper) | if (Lower <= Upper) | ||||
return false; | return false; | ||||
// However, if the range wraps around, it spans all possible values. | // However, if the range wraps around, it spans all possible values. | ||||
Lower = Type.getMinValue(); | Lower = Type.getMinValue(); | ||||
Upper = Type.getMaxValue(); | Upper = Type.getMaxValue(); | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 464 Lines • Show Last 20 Lines |