[llvm] r257796 - Assert that a cmp function defines a total order.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 14 12:28:26 PST 2016


Author: rafael
Date: Thu Jan 14 14:28:25 2016
New Revision: 257796

URL: http://llvm.org/viewvc/llvm-project?rev=257796&view=rev
Log:
Assert that a cmp function defines a total order.

Thanks to David Blaikie for noticing it.

Modified:
    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp

Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp?rev=257796&r1=257795&r2=257796&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp Thu Jan 14 14:28:25 2016
@@ -334,9 +334,8 @@ static int cmpRel(const ELFRelocationEnt
   const ELFRelocationEntry &B = *BP;
   if (A.Offset != B.Offset)
     return B.Offset - A.Offset;
-  if (B.Type != A.Type)
-    return A.Type - B.Type;
-  return 0;
+  assert(B.Type != A.Type && "We don't have a total order");
+  return A.Type - B.Type;
 }
 
 void MipsELFObjectWriter::sortRelocs(const MCAssembler &Asm,




More information about the llvm-commits mailing list