[llvm-commits] [dragonegg] r155115 - /dragonegg/trunk/src/Types.cpp
Duncan Sands
baldrick at free.fr
Thu Apr 19 03:52:17 PDT 2012
Author: baldrick
Date: Thu Apr 19 05:52:17 2012
New Revision: 155115
URL: http://llvm.org/viewvc/llvm-project?rev=155115&view=rev
Log:
For the sake of producing better debug info, gcc-4.7 restored the possibility
of having TYPE_DECL and other non-FIELD_DECL nodes in record field lists. As
this causes dragonegg to crash on just about every C++ file in its testsuite,
I'm not adding a specific testcase.
Modified:
dragonegg/trunk/src/Types.cpp
Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=155115&r1=155114&r2=155115&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Thu Apr 19 05:52:17 2012
@@ -102,6 +102,7 @@
switch (TREE_CODE(type_ref)) {
default:
+ debug_tree(type_ref);
llvm_unreachable("Unexpected tree kind!");
case ARRAY_TYPE:
case COMPLEX_TYPE:
@@ -116,7 +117,9 @@
case FIELD_DECL:
// Here type_ref is a field of the record or union type being iterated
// over. Move on to the next field.
- type_ref = TREE_CHAIN(type_ref);
+ do
+ type_ref = TREE_CHAIN(type_ref);
+ while (type_ref && !isa<FIELD_DECL>(type_ref));
break;
case FUNCTION_TYPE:
@@ -171,7 +174,10 @@
case UNION_TYPE:
// The contained types are the types of the record's fields. Use the
// first FIELD_DECL as the "pointer" to the first contained type.
- return ContainedTypeIterator(TYPE_FIELDS(type));
+ for (tree field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field))
+ if (isa<FIELD_DECL>(field))
+ return ContainedTypeIterator(field);
+ return end();
case FUNCTION_TYPE:
case METHOD_TYPE:
@@ -1092,7 +1098,8 @@
// Record all interesting fields so they can easily be visited backwards.
SmallVector<tree, 16> Fields;
for (tree field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
- assert(isa<FIELD_DECL>(field) && "Lang data not freed?");
+ if (!isa<FIELD_DECL>(field))
+ continue;
// Ignore fields with variable or unknown position since they cannot be
// represented by the LLVM type system.
if (!OffsetIsLLVMCompatible(field))
More information about the llvm-commits
mailing list