Use std::make_tuple to reduce code duplication.

Thanks to David Blaikie for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242074 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-07-13 22:01:02 +00:00
parent cc383db66a
commit 6d0b72637c

View File

@ -185,39 +185,20 @@ struct NMSymbol {
}
static bool compareSymbolAddress(const NMSymbol &A, const NMSymbol &B) {
bool AUndefined = A.Sym.getFlags() & SymbolRef::SF_Undefined;
bool BUndefined = B.Sym.getFlags() & SymbolRef::SF_Undefined;
if (AUndefined && !BUndefined)
return true;
if (!AUndefined && BUndefined)
return false;
if (A.Address < B.Address)
return true;
if (A.Address == B.Address && A.Name < B.Name)
return true;
if (A.Address == B.Address && A.Name == B.Name && A.Size < B.Size)
return true;
return false;
bool ADefined = !(A.Sym.getFlags() & SymbolRef::SF_Undefined);
bool BDefined = !(B.Sym.getFlags() & SymbolRef::SF_Undefined);
return std::make_tuple(ADefined, A.Address, A.Name, A.Size) <
std::make_tuple(BDefined, B.Address, B.Name, B.Size);
}
static bool compareSymbolSize(const NMSymbol &A, const NMSymbol &B) {
if (A.Size < B.Size)
return true;
if (A.Size == B.Size && A.Name < B.Name)
return true;
if (A.Size == B.Size && A.Name == B.Name && A.Address < B.Address)
return true;
return false;
return std::make_tuple(A.Size, A.Name, A.Address) <
std::make_tuple(B.Size, B.Name, B.Address);
}
static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) {
if (A.Name < B.Name)
return true;
if (A.Name == B.Name && A.Size < B.Size)
return true;
if (A.Name == B.Name && A.Size == B.Size && A.Address < B.Address)
return true;
return false;
return std::make_tuple(A.Name, A.Size, A.Address) <
std::make_tuple(B.Name, B.Size, B.Address);
}
static char isSymbolList64Bit(SymbolicFile &Obj) {