summaryrefslogtreecommitdiff
path: root/include/llvm/Object/ObjectFile.h
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2011-01-21 02:27:02 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2011-01-21 02:27:02 +0000
commit7acdb4d237181976b04e72f6a6c329c3b2604440 (patch)
tree35445370a1806d37b9415b998d73b5592d601438 /include/llvm/Object/ObjectFile.h
parentbe111ef1823e58bdb0bacee22368f0d9af6fbc7d (diff)
downloadllvm-7acdb4d237181976b04e72f6a6c329c3b2604440.tar.gz
llvm-7acdb4d237181976b04e72f6a6c329c3b2604440.tar.bz2
llvm-7acdb4d237181976b04e72f6a6c329c3b2604440.tar.xz
Object: Fix type punned pointer issues by making DataRefImpl a union and using intptr_t.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123962 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Object/ObjectFile.h')
-rw-r--r--include/llvm/Object/ObjectFile.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h
index b47dc69ede..eee9d447cd 100644
--- a/include/llvm/Object/ObjectFile.h
+++ b/include/llvm/Object/ObjectFile.h
@@ -16,6 +16,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DataTypes.h"
+#include <cstring>
namespace llvm {
@@ -25,7 +26,19 @@ class StringRef;
namespace object {
class ObjectFile;
-typedef uint64_t DataRefImpl;
+
+union DataRefImpl {
+ struct {
+ uint32_t a, b;
+ } d;
+ intptr_t p;
+};
+
+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;
+}
/// SymbolRef - This is a value type class that represents a single symbol in
/// the list of symbols in the object file.