IRgen: Fix CGRecordLayout::print to print the bit-field infos in a consistent order.

llvm-svn: 102044
This commit is contained in:
Daniel Dunbar 2010-04-22 02:35:36 +00:00
parent e448942b76
commit b6f4b05914
1 changed files with 14 additions and 1 deletions

View File

@ -598,13 +598,26 @@ void CGRecordLayout::print(llvm::raw_ostream &OS) const {
OS << " LLVMType:" << *LLVMType << "\n";
OS << " ContainsPointerToDataMember:" << ContainsPointerToDataMember << "\n";
OS << " BitFields:[\n";
// Print bit-field infos in declaration order.
std::vector<std::pair<unsigned, const CGBitFieldInfo*> > BFIs;
for (llvm::DenseMap<const FieldDecl*, CGBitFieldInfo>::const_iterator
it = BitFields.begin(), ie = BitFields.end();
it != ie; ++it) {
const RecordDecl *RD = it->first->getParent();
unsigned Index = 0;
for (RecordDecl::field_iterator
it2 = RD->field_begin(); *it2 != it->first; ++it2)
++Index;
BFIs.push_back(std::make_pair(Index, &it->second));
}
llvm::array_pod_sort(BFIs.begin(), BFIs.end());
for (unsigned i = 0, e = BFIs.size(); i != e; ++i) {
OS.indent(4);
it->second.print(OS);
BFIs[i].second->print(OS);
OS << "\n";
}
OS << "]>\n";
}