[cfe-commits] r58468 - /cfe/trunk/lib/Analysis/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Thu Oct 30 16:14:41 PDT 2008
Author: kremenek
Date: Thu Oct 30 18:14:36 2008
New Revision: 58468
URL: http://llvm.org/viewvc/llvm-project?rev=58468&view=rev
Log:
Handle the case in VisitInitListExprs where there are no initializers in the compound literal.
Modified:
cfe/trunk/lib/Analysis/GRExprEngine.cpp
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=58468&r1=58467&r2=58468&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Thu Oct 30 18:14:36 2008
@@ -1637,23 +1637,30 @@
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();
More information about the cfe-commits
mailing list