diff options
author | John McCall <rjmccall@apple.com> | 2012-02-15 01:22:51 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-02-15 01:22:51 +0000 |
commit | c62bb3914260c9b864dcf88e8a12ee645f5368da (patch) | |
tree | 7128c79cc1a2fea3a832f3b1505b2bcadf6e48b6 /clang/lib/CodeGen/CGCXXABI.h | |
parent | 4dd0963d56096eb3de1b6beaa5deee57be384e95 (diff) | |
download | bcm5719-llvm-c62bb3914260c9b864dcf88e8a12ee645f5368da.tar.gz bcm5719-llvm-c62bb3914260c9b864dcf88e8a12ee645f5368da.zip |
Split reinterpret_casts of member pointers out from CK_BitCast; this
is general goodness because representations of member pointers are
not always equivalent across member pointer types on all ABIs
(even though this isn't really standard-endorsed).
Take advantage of the new information to teach IR-generation how
to do these reinterprets in constant initializers. Make sure this
works when intermingled with hierarchy conversions (although
this is not part of our motivating use case). Doing this in the
constant-evaluator would probably have been better, but that would
require a *lot* of extra structure in the representation of
constant member pointers: you'd really have to track an arbitrary
chain of hierarchy conversions and reinterpretations in order to
get this right. Ultimately, this seems less complex. I also
wasn't quite sure how to extend the constant evaluator to handle
foldings that we don't actually want to treat as extended
constant expressions.
llvm-svn: 150551
Diffstat (limited to 'clang/lib/CodeGen/CGCXXABI.h')
-rw-r--r-- | clang/lib/CodeGen/CGCXXABI.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h index 4bacd014036..4e045f5f327 100644 --- a/clang/lib/CodeGen/CGCXXABI.h +++ b/clang/lib/CodeGen/CGCXXABI.h @@ -100,12 +100,17 @@ public: llvm::Value *MemPtr, const MemberPointerType *MPT); - /// Perform a derived-to-base or base-to-derived member pointer - /// conversion. + /// Perform a derived-to-base, base-to-derived, or bitcast member + /// pointer conversion. virtual llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF, const CastExpr *E, llvm::Value *Src); + /// Perform a derived-to-base, base-to-derived, or bitcast member + /// pointer conversion on a constant value. + virtual llvm::Constant *EmitMemberPointerConversion(const CastExpr *E, + llvm::Constant *Src); + /// Return true if the given member pointer can be zero-initialized /// (in the C++ sense) with an LLVM zeroinitializer. virtual bool isZeroInitializable(const MemberPointerType *MPT); @@ -137,6 +142,15 @@ public: llvm::Value *MemPtr, const MemberPointerType *MPT); +protected: + /// A utility method for computing the offset required for the given + /// base-to-derived or derived-to-base member-pointer conversion. + /// Does not handle virtual conversions (in case we ever fully + /// support an ABI that allows this). Returns null if no adjustment + /// is required. + llvm::Constant *getMemberPointerAdjustment(const CastExpr *E); + +public: /// Build the signature of the given constructor variant by adding /// any required parameters. For convenience, ResTy has been /// initialized to 'void', and ArgTys has been initialized with the |