[lld] r211704 - [mach-o]: make sure custom sort method is irreflexive.

Tim Northover tnorthover at apple.com
Wed Jun 25 08:12:55 PDT 2014


Author: tnorthover
Date: Wed Jun 25 10:12:55 2014
New Revision: 211704

URL: http://llvm.org/viewvc/llvm-project?rev=211704&view=rev
Log:
[mach-o]: make sure custom sort method is irreflexive.

The previous function returned true for "s < s", which could completely mess up
the sorting of symbols within a section.

Unfortunately, I don't think there's a robust way to write a test for this.
Anything I come up with will be making assumptions about the particular
implementation of std::sort.

Modified:
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp?rev=211704&r1=211703&r2=211704&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp Wed Jun 25 10:12:55 2014
@@ -272,8 +272,8 @@ std::error_code processSymboledSection(D
               Atom::Scope rScope = atomScope(rhs->scope);
               if (lScope != rScope)
                 return lScope < rScope;
-              // If same address and scope, sort by name.   
-              return (lhs->name.compare(rhs->name) < 1);
+              // If same address and scope, sort by name.
+              return lhs->name < rhs->name;
             });
 
   // Debug logging of symbols.





More information about the llvm-commits mailing list