summaryrefslogtreecommitdiffstats
path: root/clang
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
commita06794201d24d0bbfe797f073325fee42d1a729c (patch)
tree92d8a1baa354027357c040c93c4ae6fa3329fc05 /clang
parent8d269dc329e2f76670cc9a33ecdad76c69f83c7d (diff)
downloadbcm5719-llvm-a06794201d24d0bbfe797f073325fee42d1a729c.tar.gz
bcm5719-llvm-a06794201d24d0bbfe797f073325fee42d1a729c.zip
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
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/ExprConstant.cpp7
1 files changed, 7 insertions, 0 deletions
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
OpenPOWER on IntegriCloud