diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-04-30 21:05:35 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-04-30 21:05:35 +0000 |
commit | c52c89a5ebd7e7aea7944a666445807e8be26b1e (patch) | |
tree | 80458f9f49831b669da45444c8cd2ea91ebca694 /lib/Analysis/GRExprEngine.cpp | |
parent | c0c3f5dbc9e78aa53a86c7d5e3eeda23ddad93d6 (diff) |
When creating LVals for array entries, canonicalize entries with a 0 index.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 80e9af3190..877bd09a28 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -803,7 +803,15 @@ void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A, NodeTy* Pred, ValueState* St = GetState(*I2); RVal BaseV = GetRVal(St, Base); RVal IdxV = GetRVal(St, Idx); - RVal V = lval::ArrayOffset::Make(BasicVals, BaseV, IdxV); + + // If IdxV is 0, return just BaseV. + + bool useBase = false; + + if (nonlval::ConcreteInt* IdxInt = dyn_cast<nonlval::ConcreteInt>(&IdxV)) + useBase = IdxInt->getValue() == 0; + + RVal V = useBase ? BaseV : lval::ArrayOffset::Make(BasicVals, BaseV,IdxV); if (asLVal) MakeNode(Dst, A, *I2, SetRVal(St, A, V)); |