aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BasicConstraintManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/BasicConstraintManager.cpp')
-rw-r--r--lib/Analysis/BasicConstraintManager.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Analysis/BasicConstraintManager.cpp b/lib/Analysis/BasicConstraintManager.cpp
index a359b23c54..6f62c4ba77 100644
--- a/lib/Analysis/BasicConstraintManager.cpp
+++ b/lib/Analysis/BasicConstraintManager.cpp
@@ -369,8 +369,14 @@ BasicConstraintManager::AssumeInBound(const GRState* St, SVal Idx,
}
const llvm::APSInt& Zero = getBasicVals().getZeroWithPtrWidth(false);
- const llvm::APSInt& IdxV = cast<nonloc::ConcreteInt>(Idx).getValue();
- const llvm::APSInt& UBV = cast<nonloc::ConcreteInt>(UpperBound).getValue();
+ llvm::APSInt IdxV = cast<nonloc::ConcreteInt>(Idx).getValue();
+ // IdxV might be too narrow.
+ if (IdxV.getBitWidth() < Zero.getBitWidth())
+ IdxV.extend(Zero.getBitWidth());
+ // UBV might be too narrow, too.
+ llvm::APSInt UBV = cast<nonloc::ConcreteInt>(UpperBound).getValue();
+ if (UBV.getBitWidth() < Zero.getBitWidth())
+ UBV.extend(Zero.getBitWidth());
bool InBound = (Zero <= IdxV) && (IdxV < UBV);