[llvm-commits] [dragonegg] r137606 - /dragonegg/trunk/src/Constants.cpp
Duncan Sands
baldrick at free.fr
Mon Aug 15 01:20:05 PDT 2011
Author: baldrick
Date: Mon Aug 15 03:20:05 2011
New Revision: 137606
URL: http://llvm.org/viewvc/llvm-project?rev=137606&view=rev
Log:
When processing a constructor and default initializing the fields
which did not get an explicit constructor entry, default initialize
in reverse order to ensure that the first field of a union is always
default initialized. This is a theoretical fix since I failed to
construct a testcase for which this made a difference.
Modified:
dragonegg/trunk/src/Constants.cpp
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=137606&r1=137605&r2=137606&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Mon Aug 15 03:20:05 2011
@@ -1076,9 +1076,18 @@
// initial value is supplied for a field then the value will overwrite and
// replace the zero starting value later.
if (flag_default_initialize_globals) {
+ // Process the fields in reverse order. This is for the benefit of union
+ // types for which the first field must be default initialized (iterating
+ // in forward order would default initialize the last field).
+ SmallVector<tree, 16> Fields;
for (tree field = TYPE_FIELDS(TREE_TYPE(exp)); field;
field = TREE_CHAIN(field)) {
assert(TREE_CODE(field) == FIELD_DECL && "Lang data not freed?");
+ Fields.push_back(field);
+ }
+ for (SmallVector<tree, 16>::reverse_iterator I = Fields.rbegin(),
+ E = Fields.rend(); I != E; ++I) {
+ tree field = *I;
// If the field has variable or unknown position then it cannot be default
// initialized - skip it.
if (!OffsetIsLLVMCompatible(field))
More information about the llvm-commits
mailing list