From a06794201d24d0bbfe797f073325fee42d1a729c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 13 Apr 2010 17:34:23 +0000 Subject: 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}, }; llvm-svn: 101150 --- clang/lib/AST/ExprConstant.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/lib/AST/ExprConstant.cpp') diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index eeeeb5c836b..c9aff6408fa 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/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 -- cgit v1.2.3