[llvm] r203294 - [C++11] Revert uses of lambdas with array_pod_sort.

Benjamin Kramer benny.kra at googlemail.com
Fri Mar 7 13:52:38 PST 2014


Author: d0k
Date: Fri Mar  7 15:52:38 2014
New Revision: 203294

URL: http://llvm.org/viewvc/llvm-project?rev=203294&view=rev
Log:
[C++11] Revert uses of lambdas with array_pod_sort.

Looks like GCC implements the lambda->function pointer conversion differently.

Modified:
    llvm/trunk/lib/Support/TargetRegistry.cpp
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp

Modified: llvm/trunk/lib/Support/TargetRegistry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/TargetRegistry.cpp?rev=203294&r1=203293&r2=203294&view=diff
==============================================================================
--- llvm/trunk/lib/Support/TargetRegistry.cpp (original)
+++ llvm/trunk/lib/Support/TargetRegistry.cpp Fri Mar  7 15:52:38 2014
@@ -127,6 +127,11 @@ const Target *TargetRegistry::getClosest
   return TheTarget;
 }
 
+static int TargetArraySortFn(const std::pair<StringRef, const Target *> *LHS,
+                             const std::pair<StringRef, const Target *> *RHS) {
+  return LHS->first.compare(RHS->first);
+}
+
 void TargetRegistry::printRegisteredTargetsForVersion() {
   std::vector<std::pair<StringRef, const Target*> > Targets;
   size_t Width = 0;
@@ -136,11 +141,7 @@ void TargetRegistry::printRegisteredTarg
     Targets.push_back(std::make_pair(I->getName(), &*I));
     Width = std::max(Width, Targets.back().first.size());
   }
-  array_pod_sort(Targets.begin(), Targets.end(),
-                 [](const std::pair<StringRef, const Target *> *LHS,
-                    const std::pair<StringRef, const Target *> *RHS) {
-    return LHS->first.compare(RHS->first);
-  });
+  array_pod_sort(Targets.begin(), Targets.end(), TargetArraySortFn);
 
   raw_ostream &OS = outs();
   OS << "  Registered Targets:\n";

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=203294&r1=203293&r2=203294&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Fri Mar  7 15:52:38 2014
@@ -2860,6 +2860,10 @@ bool GlobalOpt::OptimizeGlobalCtorsList(
   return true;
 }
 
+static int compareNames(Constant *const *A, Constant *const *B) {
+  return (*A)->getName().compare((*B)->getName());
+}
+
 static void setUsedInitializer(GlobalVariable &V,
                                SmallPtrSet<GlobalValue *, 8> Init) {
   if (Init.empty()) {
@@ -2878,10 +2882,7 @@ static void setUsedInitializer(GlobalVar
     UsedArray.push_back(Cast);
   }
   // Sort to get deterministic order.
-  array_pod_sort(UsedArray.begin(), UsedArray.end(),
-                 [](Constant *const *A, Constant *const *B) {
-    return (*A)->getName().compare((*B)->getName());
-  });
+  array_pod_sort(UsedArray.begin(), UsedArray.end(), compareNames);
   ArrayType *ATy = ArrayType::get(Int8PtrTy, UsedArray.size());
 
   Module *M = V.getParent();





More information about the llvm-commits mailing list