diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -711,17 +711,17 @@ const std::string &ArchiveName, const std::string &ArchitectureName) { if (!NoSort) { - std::function Cmp; - if (NumericSort) - Cmp = compareSymbolAddress; - else if (SizeSort) - Cmp = compareSymbolSize; - else - Cmp = compareSymbolName; + using Comparator = bool (*)(const NMSymbol &, const NMSymbol &); + Comparator Cmp = NumericSort + ? &compareSymbolAddress + : (SizeSort ? &compareSymbolSize : &compareSymbolName); if (ReverseSort) - Cmp = [=](const NMSymbol &A, const NMSymbol &B) { return Cmp(B, A); }; - llvm::sort(SymbolList, Cmp); + llvm::sort(SymbolList, [=](const NMSymbol &A, const NMSymbol &B) -> bool { + return Cmp(B, A); + }); + else + llvm::sort(SymbolList, Cmp); } if (!PrintFileName) {