llvm-vtabledump: use a std::map instead of a StringMap for VBTables

StringMap doesn't guarantee any particular iteration order,
this is suboptimal when comparing llvm-vtabledump's output for two
object files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213921 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2014-07-25 04:30:11 +00:00
parent 2048bc28ff
commit b984536dad

View File

@ -15,7 +15,6 @@
#include "llvm-vtabledump.h"
#include "Error.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Debug.h"
@ -71,7 +70,7 @@ static void reportError(StringRef Input, std::error_code EC) {
static void dumpVTables(const ObjectFile *Obj) {
std::map<std::pair<StringRef, uint64_t>, StringRef> VFTableEntries;
StringMap<ArrayRef<aligned_little32_t>> VBTables;
std::map<StringRef, ArrayRef<aligned_little32_t>> VBTables;
for (const object::SymbolRef &Sym : Obj->symbols()) {
StringRef SymName;
if (error(Sym.getName(SymName)))
@ -126,12 +125,13 @@ static void dumpVTables(const ObjectFile *Obj) {
StringRef SymName = VFTableEntry.second;
outs() << VFTableName << '[' << Offset << "]: " << SymName << '\n';
}
for (const StringMapEntry<ArrayRef<aligned_little32_t>> &VBTable : VBTables) {
StringRef VBTableName = VBTable.getKey();
for (const std::pair<StringRef, ArrayRef<aligned_little32_t>> &VBTable :
VBTables) {
StringRef VBTableName = VBTable.first;
uint32_t Idx = 0;
for (aligned_little32_t Offset : VBTable.getValue()) {
for (aligned_little32_t Offset : VBTable.second) {
outs() << VBTableName << '[' << Idx << "]: " << Offset << '\n';
Idx += sizeof(aligned_little32_t);
Idx += sizeof(Offset);
}
}
}