Use std::make_tuple to reduce code duplication.

Thanks to David Blaikie for the suggestion.

llvm-svn: 242074
This commit is contained in:
Rafael Espindola 2015-07-13 22:01:02 +00:00
parent 1a550c0a87
commit 45592c64f3
1 changed files with 8 additions and 27 deletions

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) {