summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2011-11-02 19:33:41 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2011-11-02 19:33:41 +0000
commit3314c26475b5561abbfe0785e0a64d189d5b4060 (patch)
treee4263e7d602c3063592e76c4bcb34327410c1746 /include
parent783d88793afe4b4e42460c139ab742fbd26f39f7 (diff)
downloadllvm-3314c26475b5561abbfe0785e0a64d189d5b4060.tar.gz
llvm-3314c26475b5561abbfe0785e0a64d189d5b4060.tar.bz2
llvm-3314c26475b5561abbfe0785e0a64d189d5b4060.tar.xz
object: Add operator < for SymbolRef and SectionRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143563 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Object/ObjectFile.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h
index 947e290c8c..a0f3c4bdca 100644
--- a/include/llvm/Object/ObjectFile.h
+++ b/include/llvm/Object/ObjectFile.h
@@ -78,6 +78,12 @@ static bool operator ==(const DataRefImpl &a, const DataRefImpl &b) {
return std::memcmp(&a, &b, sizeof(DataRefImpl)) == 0;
}
+static bool operator <(const DataRefImpl &a, const DataRefImpl &b) {
+ // Check bitwise identical. This is the only legal way to compare a union w/o
+ // knowing which member is in use.
+ return std::memcmp(&a, &b, sizeof(DataRefImpl)) < 0;
+}
+
class SymbolRef;
/// RelocationRef - This is a value type class that represents a single
@@ -135,6 +141,7 @@ public:
SectionRef(DataRefImpl SectionP, const ObjectFile *Owner);
bool operator==(const SectionRef &Other) const;
+ bool operator <(const SectionRef &Other) const;
error_code getNext(SectionRef &Result) const;
@@ -182,6 +189,7 @@ public:
SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
bool operator==(const SymbolRef &Other) const;
+ bool operator <(const SymbolRef &Other) const;
error_code getNext(SymbolRef &Result) const;
@@ -339,6 +347,10 @@ inline bool SymbolRef::operator==(const SymbolRef &Other) const {
return SymbolPimpl == Other.SymbolPimpl;
}
+inline bool SymbolRef::operator <(const SymbolRef &Other) const {
+ return SymbolPimpl < Other.SymbolPimpl;
+}
+
inline error_code SymbolRef::getNext(SymbolRef &Result) const {
return OwningObject->getSymbolNext(SymbolPimpl, Result);
}
@@ -402,6 +414,10 @@ inline bool SectionRef::operator==(const SectionRef &Other) const {
return SectionPimpl == Other.SectionPimpl;
}
+inline bool SectionRef::operator <(const SectionRef &Other) const {
+ return SectionPimpl < Other.SectionPimpl;
+}
+
inline error_code SectionRef::getNext(SectionRef &Result) const {
return OwningObject->getSectionNext(SectionPimpl, Result);
}