diff options
author | Anders Carlsson <andersca@mac.com> | 2009-10-18 18:12:03 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-10-18 18:12:03 +0000 |
commit | 82debc7d282e723e58d183bfa89ddc2500a8daaf (patch) | |
tree | cdab83016d60bd68811bfbc05411a4d41ed456bb /lib/CodeGen | |
parent | b14346b95e728f3f9425f9c2dc7973875874eb38 (diff) |
Add some more cast kinds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 422e2b65bc..d986549555 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -700,7 +700,16 @@ Value *ScalarExprEmitter::EmitCastExpr(const CastExpr *CE) { case CastExpr::CK_IntegralToPointer: { Value *Src = Visit(const_cast<Expr*>(E)); - return Builder.CreateIntToPtr(Src, ConvertType(DestTy)); + + // First, convert to the correct width so that we control the kind of + // extension. + const llvm::Type *MiddleTy = + llvm::IntegerType::get(VMContext, CGF.LLVMPointerWidth); + bool InputSigned = E->getType()->isSignedIntegerType(); + llvm::Value* IntResult = + Builder.CreateIntCast(Src, MiddleTy, InputSigned, "conv"); + + return Builder.CreateIntToPtr(IntResult, ConvertType(DestTy)); } case CastExpr::CK_PointerToIntegral: { |