[mach-o]: make sure custom sort method is irreflexive.
authorTim Northover <tnorthover@apple.com>
Wed, 25 Jun 2014 15:12:55 +0000 (15:12 +0000)
committerTim Northover <tnorthover@apple.com>
Wed, 25 Jun 2014 15:12:55 +0000 (15:12 +0000)
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.

llvm-svn: 211704

lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp

index 1a03ede..a582c97 100644 (file)
@@ -272,8 +272,8 @@ std::error_code processSymboledSection(DefinedAtom::ContentType atomType,
               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.