From 7fe0b9ea2c8137c035402e6ea01dfdfbc93214cb Mon Sep 17 00:00:00 2001 From: John McCall Date: Sat, 13 Feb 2010 01:04:05 +0000 Subject: Switch the standard DeclarationName comparator to be a tri-valued comparator. Use that while fixing a nasty misuse of qsort in vtable codegen which, somehow, has not actually caused a crash. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96062 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGVtable.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/CodeGen/CGVtable.cpp') diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index a5ba11f8ba..8c172a2134 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -1109,9 +1109,10 @@ private: } static int DclCmp(const void *p1, const void *p2) { - const CXXMethodDecl *MD1 = (const CXXMethodDecl *)p1; - const CXXMethodDecl *MD2 = (const CXXMethodDecl *)p2; - return (MD1->getIdentifier() - MD2->getIdentifier()); + const CXXMethodDecl *MD1 = *(const CXXMethodDecl *const *)p1; + const CXXMethodDecl *MD2 = *(const CXXMethodDecl *const *)p2; + + return (DeclarationName::compare(MD1->getDeclName(), MD2->getDeclName())); } void MergeForwarding() { @@ -1127,7 +1128,7 @@ private: for (A_t::iterator I = A.begin(), E = A.end(); I != E; ++I) { A_t::iterator J = I; - while (++J != E && DclCmp(*I, *J) == 0) + while (++J != E && DclCmp(I, J) == 0) if (DclIsSame(*I, *J)) { if (0) printf("connecting %s\n", (*I)->getNameAsCString()); ForwardUnique[*J] = *I; -- cgit v1.2.3