From: Daniel Dunbar Date: Thu, 22 Apr 2010 02:35:36 +0000 (+0000) Subject: IRgen: Fix CGRecordLayout::print to print the bit-field infos in a consistent order. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad759530ff48385255c25e71d7e05632361e0c11;p=clang IRgen: Fix CGRecordLayout::print to print the bit-field infos in a consistent order. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102044 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index fe28495e5d..71d0290548 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -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 > BFIs; for (llvm::DenseMap::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"; }