]> granicus.if.org Git - clang/commitdiff
RegionStore::getLValueElement: Handle the case where the signedness of the
authorTed Kremenek <kremenek@apple.com>
Wed, 11 Mar 2009 04:04:20 +0000 (04:04 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 11 Mar 2009 04:04:20 +0000 (04:04 +0000)
offset may be different that the base. Ultimately we need a better solution for
these issues, but this point-by-point fixes are gradually outlining the scope of
the problem.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66638 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/RegionStore.cpp

index 2f4d70a577a0d1895d91f61f567b7ce24f08abb7..6253e6182f4b76e7757bcddf080e56883ee4e985 100644 (file)
@@ -630,8 +630,12 @@ SVal RegionStoreManager::EvalBinOp(BinaryOperator::Opcode Op, Loc L, NonLoc R) {
 
   // Only support concrete integer indexes for now.
   if (Base && Offset) {
-    SVal NewIdx = Base->EvalBinOp(getBasicVals(), Op, *Offset);
-
+    // For now, convert the signedness of offset in case it doesn't match.
+    const llvm::APSInt &I =
+      getBasicVals().ConvertSignedness(Base->getValue(), Offset->getValue());    
+    nonloc::ConcreteInt OffsetConverted(I);
+    
+    SVal NewIdx = Base->EvalBinOp(getBasicVals(), Op, OffsetConverted);
     const MemRegion* NewER = MRMgr.getElementRegion(NewIdx, 
                                                     ER->getArrayRegion());
     return Loc::MakeVal(NewER);