mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-04 17:26:05 +00:00
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
This commit is contained in:
parent
8d269dc329
commit
a06794201d
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user