diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-11-24 19:35:33 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-11-24 19:35:33 +0000 |
commit | 81c1e1306ce713fb54cef700581987d0f5038f52 (patch) | |
tree | 3d10f6ef9821e6c676b5acd92e86b6a78a04c918 /clang/lib/Analysis/BasicConstraintManager.cpp | |
parent | 01c414c070abfc22f22693208af85555b2021771 (diff) | |
download | bcm5719-llvm-81c1e1306ce713fb54cef700581987d0f5038f52.tar.gz bcm5719-llvm-81c1e1306ce713fb54cef700581987d0f5038f52.zip |
Fix crash of array bounds checking under 64-bit.
There might be other, similar bugs lurking there.
llvm-svn: 59974
Diffstat (limited to 'clang/lib/Analysis/BasicConstraintManager.cpp')
-rw-r--r-- | clang/lib/Analysis/BasicConstraintManager.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Analysis/BasicConstraintManager.cpp b/clang/lib/Analysis/BasicConstraintManager.cpp index a359b23c549..6f62c4ba772 100644 --- a/clang/lib/Analysis/BasicConstraintManager.cpp +++ b/clang/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); |