Changes in directory llvm/lib/Target/CBackend:
Writer.cpp updated: 1.250 -> 1.251 --- Log message: Simplify CWriter::printContainedStructs, also allowing it to work with PackedTypes as a side-effect. --- Diffs of the changes: (+11 -18) Writer.cpp | 29 +++++++++++------------------ 1 files changed, 11 insertions(+), 18 deletions(-) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.250 llvm/lib/Target/CBackend/Writer.cpp:1.251 --- llvm/lib/Target/CBackend/Writer.cpp:1.250 Tue Dec 27 04:40:34 2005 +++ llvm/lib/Target/CBackend/Writer.cpp Fri Jan 20 12:57:03 2006 @@ -1037,29 +1037,22 @@ // this one depends on. void CWriter::printContainedStructs(const Type *Ty, std::set<const StructType*> &StructPrinted){ + // Don't walk through pointers. + if (isa<PointerType>(Ty) || Ty->isPrimitiveType()) return; + + // Print all contained types first. + for (Type::subtype_iterator I = Ty->subtype_begin(), + E = Ty->subtype_end(); I != E; ++I) + printContainedStructs(*I, StructPrinted); + if (const StructType *STy = dyn_cast<StructType>(Ty)) { - //Check to see if we have already printed this struct - if (StructPrinted.count(STy) == 0) { - // Print all contained types first... - for (StructType::element_iterator I = STy->element_begin(), - E = STy->element_end(); I != E; ++I) { - const Type *Ty1 = I->get(); - if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1)) - printContainedStructs(*I, StructPrinted); - } - - //Print structure type out.. - StructPrinted.insert(STy); + // Check to see if we have already printed this struct. + if (StructPrinted.insert(STy).second) { + // Print structure type out. std::string Name = TypeNames[STy]; printType(Out, STy, Name, true); Out << ";\n\n"; } - - // If it is an array, check contained types and continue - } else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)){ - const Type *Ty1 = ATy->getElementType(); - if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1)) - printContainedStructs(Ty1, StructPrinted); } } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits