diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-10-30 23:14:36 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-10-30 23:14:36 +0000 |
commit | a49e3674e44104e34342d2c35ece7cb4f9bd96cb (patch) | |
tree | 819a31feb7a0c53575daf4a72839d749344a5e4d | |
parent | ccb55e3d0c173ed86ab440d9bf41c06fdddd39ef (diff) |
Handle the case in VisitInitListExprs where there are no initializers in the compound literal.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58468 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index c8d4722442..9995a397fc 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -1637,23 +1637,30 @@ public: void GRExprEngine::VisitInitListExpr(InitListExpr* E, NodeTy* Pred, NodeSet& Dst) { - const GRState* state = GetState(Pred); + const GRState* state = GetState(Pred); QualType T = E->getType(); - unsigned NumInitElements = E->getNumInits(); if (T->isArrayType() || T->isStructureType()) { - - llvm::SmallVector<InitListWLItem, 10> WorkList; - WorkList.reserve(NumInitElements); - - WorkList.push_back(InitListWLItem(Pred, getBasicVals().getEmptySValList(), - E->rbegin())); + llvm::ImmutableList<SVal> StartVals = getBasicVals().getEmptySValList(); + // Handle base case where the initializer has no elements. + // e.g: static int* myArray[] = {}; + if (NumInitElements == 0) { + SVal V = NonLoc::MakeCompoundVal(T, StartVals, getBasicVals()); + MakeNode(Dst, E, Pred, BindExpr(state, E, V)); + return; + } + + // Create a worklist to process the initializers. + llvm::SmallVector<InitListWLItem, 10> WorkList; + WorkList.reserve(NumInitElements); + WorkList.push_back(InitListWLItem(Pred, StartVals, E->rbegin())); InitListExpr::reverse_iterator ItrEnd = E->rend(); + // Process the worklist until it is empty. while (!WorkList.empty()) { InitListWLItem X = WorkList.back(); WorkList.pop_back(); |