[llvm-commits] [dragonegg] r130494 - in /dragonegg/trunk/src: Constants.cpp Types.cpp
Duncan Sands
baldrick at free.fr
Fri Apr 29 03:34:45 PDT 2011
Author: baldrick
Date: Fri Apr 29 05:34:45 2011
New Revision: 130494
URL: http://llvm.org/viewvc/llvm-project?rev=130494&view=rev
Log:
By the time a record or union type gets to the plugin it will only
contain FIELD_DECLs, thanks to the free_lang_data pass.
Modified:
dragonegg/trunk/src/Constants.cpp
dragonegg/trunk/src/Types.cpp
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130494&r1=130493&r2=130494&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Fri Apr 29 05:34:45 2011
@@ -1060,9 +1060,7 @@
if (flag_default_initialize_globals) {
for (tree field = TYPE_FIELDS(TREE_TYPE(exp)); field;
field = TREE_CHAIN(field)) {
- // Skip contained methods, types etc.
- if (TREE_CODE(field) != FIELD_DECL)
- continue;
+ assert(TREE_CODE(field) == FIELD_DECL && "Lang data not freed?");
// If the field has variable or unknown position then it cannot be default
// initialized - skip it.
if (!OffsetIsLLVMCompatible(field))
Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=130494&r1=130493&r2=130494&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Fri Apr 29 05:34:45 2011
@@ -582,17 +582,14 @@
if (TYPE_TRANSPARENT_AGGR(type)) {
tree Field = TYPE_FIELDS(type);
assert(Field && "Transparent union must have some elements!");
- while (TREE_CODE(Field) != FIELD_DECL) {
- Field = TREE_CHAIN(Field);
- assert(Field && "Transparent union must have some elements!");
- }
+ assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?");
return GCCTypeOverlapsWithPadding(TREE_TYPE(Field),
PadStartBits, PadSizeBits);
}
// See if any elements overlap.
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
- if (TREE_CODE(Field) != FIELD_DECL) continue;
+ assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?");
assert(getFieldOffsetInBits(Field) == 0 && "Union with non-zero offset?");
// Skip fields that are known not to be present.
if (TREE_CODE(type) == QUAL_UNION_TYPE &&
@@ -614,7 +611,7 @@
case RECORD_TYPE:
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
- if (TREE_CODE(Field) != FIELD_DECL) continue;
+ assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?");
if (!OffsetIsLLVMCompatible(Field))
// Variable or humongous offset.
@@ -1795,8 +1792,8 @@
unsigned ExtraSizeInBits = 0;
tree LastBitField = 0;
for (tree f = TREE_CHAIN(Field); f; f = TREE_CHAIN(f)) {
- if (TREE_CODE(f) != FIELD_DECL ||
- TREE_CODE(DECL_FIELD_OFFSET(f)) != INTEGER_CST)
+ assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?");
+ if (TREE_CODE(DECL_FIELD_OFFSET(f)) != INTEGER_CST)
break;
if (isBitfield(f))
LastBitField = f;
@@ -1890,7 +1887,7 @@
/// offsets that are zero, e.g., no Fortran equivalences.
static bool UnionHasOnlyZeroOffsets(tree type) {
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
- if (TREE_CODE(Field) != FIELD_DECL) continue;
+ assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?");
if (!OffsetIsLLVMCompatible(Field))
return false;
if (getFieldOffsetInBits(Field) != 0)
@@ -1913,7 +1910,7 @@
unsigned MinAlign = ~0U;
uint64_t BestSize = FindBiggest ? 0 : ~(uint64_t)0;
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
- if (TREE_CODE(Field) != FIELD_DECL) continue;
+ assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?");
assert(DECL_FIELD_OFFSET(Field) && integer_zerop(DECL_FIELD_OFFSET(Field))
&& "Union with non-zero offset?");
@@ -2015,9 +2012,11 @@
// Record those fields which will be converted to LLVM fields.
SmallVector<std::pair<tree, uint64_t>, 32> Fields;
- for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))
- if (TREE_CODE(Field) == FIELD_DECL && OffsetIsLLVMCompatible(Field))
+ for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
+ assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?");
+ if (OffsetIsLLVMCompatible(Field))
Fields.push_back(std::make_pair(Field, getFieldOffsetInBits(Field)));
+ }
// The fields are almost always sorted, but occasionally not. Sort them by
// field offset.
More information about the llvm-commits
mailing list