]> granicus.if.org Git - llvm/commitdiff
Fix nm on GCC 5.1 after the C++14 move
authorJF Bastien <jfbastien@apple.com>
Thu, 15 Aug 2019 20:38:42 +0000 (20:38 +0000)
committerJF Bastien <jfbastien@apple.com>
Thu, 15 Aug 2019 20:38:42 +0000 (20:38 +0000)
Summary:
As in D66306, fix the invocation of std::sort with std::function by not using
std::function, since it's easier to read and is broken in libstdc++ from GCC 5.1
(see https://gcc.gnu.org/PR65942).

Reviewers: thakis

Subscribers: jkorous, mgrang, dexonsmith, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66310

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369045 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-nm/llvm-nm.cpp

index 465f7de6857d5fcbeaa5213258edc6d5cef5f7f3..b2cc8fba1777cf3b303552c10f1e0fdd9dc8f4b9 100644 (file)
@@ -711,17 +711,21 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
                                    const std::string &ArchiveName,
                                    const std::string &ArchitectureName) {
   if (!NoSort) {
-    std::function<bool(const NMSymbol &, const NMSymbol &)> Cmp;
+    using Comparator = bool (*)(const NMSymbol &, const NMSymbol &);
+    Comparator Cmp;
     if (NumericSort)
-      Cmp = compareSymbolAddress;
+      Cmp = &compareSymbolAddress;
     else if (SizeSort)
-      Cmp = compareSymbolSize;
+      Cmp = &compareSymbolSize;
     else
-      Cmp = compareSymbolName;
+      Cmp = &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) {