summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-10-30 23:14:36 +0000
committerTed Kremenek <kremenek@apple.com>2008-10-30 23:14:36 +0000
commit828e6dff9b0eb10b7aa1cea7cec55b740a8a4804 (patch)
tree4d1e905f1566b232fe2d8f52dde193606e32bb97 /clang
parentae4d61efb224964fed6ea3d85c75e0e90b28679f (diff)
downloadbcm5719-llvm-828e6dff9b0eb10b7aa1cea7cec55b740a8a4804.tar.gz
bcm5719-llvm-828e6dff9b0eb10b7aa1cea7cec55b740a8a4804.zip
Handle the case in VisitInitListExprs where there are no initializers in the compound literal.
llvm-svn: 58468
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Analysis/GRExprEngine.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp
index c8d4722442a..9995a397fc4 100644
--- a/clang/lib/Analysis/GRExprEngine.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud