aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-13 17:34:23 +0000
committerChris Lattner <sabre@nondot.org>2010-04-13 17:34:23 +0000
commit363ff23cfddb51abe4ee4212a6dd3c9b534fcc8b (patch)
treee2e545cd763c9f17e2705590a7cdc04aa4538df8 /lib
parent553e583e1d30fe30ac2de3526536bbebee6da1ce (diff)
Teach HasSideEffect about InitListExprs. Not having
this caused us to codegen dead globals like this: struct foo { int a; int b; }; static struct foo fooarray[] = { {1, 2}, {4}, }; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ExprConstant.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index eeeeb5c836..c9aff6408f 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -203,6 +203,13 @@ public:
return Visit(E->getSubExpr());
}
bool VisitUnaryOperator(UnaryOperator *E) { return Visit(E->getSubExpr()); }
+
+ // Has side effects if any element does.
+ bool VisitInitListExpr(InitListExpr *E) {
+ for (unsigned i = 0, e = E->getNumInits(); i != e; ++i)
+ if (Visit(E->getInit(i))) return true;
+ return false;
+ }
};
} // end anonymous namespace