aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ValueManager.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-07-16 01:32:00 +0000
committerTed Kremenek <kremenek@apple.com>2009-07-16 01:32:00 +0000
commit06669c8e5c24251f6b140298148fbe53ab70a936 (patch)
tree77a2453a15694d4b74532334766ae8dbee0f6e39 /lib/Analysis/ValueManager.cpp
parentf23ecd91bf0205b776dfab2c5231e895019a7400 (diff)
Two changes:
(1) Moved the SValuator object from GRExprEngine to ValueManager. This allows ValueManager to use the SValuator when creating SVals. (2) Added ValueManager::makeArrayIndex() and ValueManager::convertToArrayIndex(), two SVal creation methods that will help RegionStoreManager always have a consistent set of SVals with the same integer size and type when reasoning about array indices. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75882 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ValueManager.cpp')
-rw-r--r--lib/Analysis/ValueManager.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Analysis/ValueManager.cpp b/lib/Analysis/ValueManager.cpp
index c9e24223df..62d8b0093b 100644
--- a/lib/Analysis/ValueManager.cpp
+++ b/lib/Analysis/ValueManager.cpp
@@ -55,6 +55,17 @@ NonLoc ValueManager::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
}
+SVal ValueManager::convertToArrayIndex(SVal V) {
+ // Common case: we have an appropriately sized integer.
+ if (nonloc::ConcreteInt* CI = dyn_cast<nonloc::ConcreteInt>(&V)) {
+ const llvm::APSInt& I = CI->getValue();
+ if (I.getBitWidth() == ArrayIndexWidth && I.isSigned())
+ return V;
+ }
+
+ return SVator->EvalCast(V, ArrayIndexTy);
+}
+
SVal ValueManager::getRegionValueSymbolVal(const MemRegion* R, QualType T) {
SymbolRef sym = SymMgr.getRegionValueSymbol(R, T);