[cfe-commits] r102044 - /cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp

Daniel Dunbar daniel at zuster.org
Wed Apr 21 19:35:36 PDT 2010


Author: ddunbar
Date: Wed Apr 21 21:35:36 2010
New Revision: 102044

URL: http://llvm.org/viewvc/llvm-project?rev=102044&view=rev
Log:
IRgen: Fix CGRecordLayout::print to print the bit-field infos in a consistent order.

Modified:
    cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp

Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=102044&r1=102043&r2=102044&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Wed Apr 21 21:35:36 2010
@@ -598,13 +598,26 @@
   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";
 }
 





More information about the cfe-commits mailing list