diff options
author | Anders Carlsson <andersca@mac.com> | 2010-03-22 16:30:44 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-03-22 16:30:44 +0000 |
commit | 87e0ac81f8ad3b6a05df0febb44dff9a6a62036a (patch) | |
tree | 89c1ff6e023b7d55d474f12b4886f9fb126eedff /lib/CodeGen/CGVtable.cpp | |
parent | 09daa50ff77f166f9d5cc30a6fc6c827fc5e44db (diff) |
Add less than operators to ThisAdjustment, ReturnAdjustment and ThunkInfo. Sort the thunks before dumping them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99184 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVtable.cpp')
-rw-r--r-- | lib/CodeGen/CGVtable.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index 2c3bd8646c..b78867841c 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -1154,6 +1154,15 @@ private: return LHS.NonVirtual == RHS.NonVirtual && LHS.VBaseOffsetOffset == RHS.VBaseOffsetOffset; } + + friend bool operator<(const ReturnAdjustment &LHS, + const ReturnAdjustment &RHS) { + if (LHS.NonVirtual < RHS.NonVirtual) + return true; + + return LHS.NonVirtual == RHS.NonVirtual && + LHS.VBaseOffsetOffset < RHS.VBaseOffsetOffset; + } }; /// MethodInfo - Contains information about a method in a vtable. @@ -1204,6 +1213,16 @@ private: return LHS.NonVirtual == RHS.NonVirtual && LHS.VCallOffsetOffset == RHS.VCallOffsetOffset; } + + friend bool operator<(const ThisAdjustment &LHS, + const ThisAdjustment &RHS) { + if (LHS.NonVirtual < RHS.NonVirtual) + return true; + + return LHS.NonVirtual == RHS.NonVirtual && + LHS.VCallOffsetOffset < RHS.VCallOffsetOffset; + } + }; /// ThunkInfo - The 'this' pointer adjustment as well as an optional return @@ -1224,6 +1243,13 @@ private: return LHS.This == RHS.This && LHS.Return == RHS.Return; } + friend bool operator<(const ThunkInfo &LHS, const ThunkInfo &RHS) { + if (LHS.This < RHS.This) + return true; + + return LHS.This == RHS.This && LHS.Return < RHS.Return; + } + bool isEmpty() const { return This.isEmpty() && Return.isEmpty(); } }; @@ -2296,7 +2322,9 @@ void VtableBuilder::dumpLayout(llvm::raw_ostream& Out) { I != E; ++I) { const std::string &MethodName = I->first; const CXXMethodDecl *MD = I->second; - const llvm::SmallVector<ThunkInfo, 1> &ThunksVector = MethodThunks[MD]; + + llvm::SmallVector<ThunkInfo, 1> ThunksVector = MethodThunks[MD]; + std::sort(ThunksVector.begin(), ThunksVector.end()); Out << "Thunks for '" << MethodName << "' (" << ThunksVector.size(); Out << (ThunksVector.size() == 1 ? " entry" : " entries") << ").\n"; |