summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2008-11-13 09:15:14 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2008-11-13 09:15:14 +0000
commit189a30796a7e1aaa38ff8e2acdc35789c5c54809 (patch)
tree42aff2ec827ef2a3b57a07b6b8e83228883dfc91 /clang/lib
parent9182147f173e174b03da52e84fe1de387b26dcf7 (diff)
downloadbcm5719-llvm-189a30796a7e1aaa38ff8e2acdc35789c5c54809.tar.gz
bcm5719-llvm-189a30796a7e1aaa38ff8e2acdc35789c5c54809.zip
Array index might be unsigned. We have to generate a temporary signed value for
it to be evaluated by APSInt::operators. llvm-svn: 59238
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/RegionStore.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp
index 562d5845588..ec5acf57f4e 100644
--- a/clang/lib/Analysis/RegionStore.cpp
+++ b/clang/lib/Analysis/RegionStore.cpp
@@ -197,6 +197,18 @@ SVal RegionStoreManager::getLValueElement(const GRState* St,
// Only handle integer indices for now.
if ((CI1 = dyn_cast<nonloc::ConcreteInt>(&Idx)) &&
(CI2 = dyn_cast<nonloc::ConcreteInt>(&Offset))) {
+
+ // Temporary SVal to hold a potential signed APSInt.
+ SVal SignedInt;
+
+ // Index might be unsigned. We have to convert it to signed.
+ if (CI2->getValue().isUnsigned()) {
+ llvm::APSInt SI = CI2->getValue();
+ SI.setIsSigned(true);
+ SignedInt = nonloc::ConcreteInt(getBasicVals().getValue(SI));
+ CI2 = cast<nonloc::ConcreteInt>(&SignedInt);
+ }
+
SVal NewIdx = CI1->EvalBinOp(StateMgr.getBasicVals(), BinaryOperator::Add,
*CI2);
return loc::MemRegionVal(MRMgr.getElementRegion(NewIdx,
OpenPOWER on IntegriCloud