diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-08-25 09:51:32 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-08-25 09:51:32 +0000 |
commit | 270cc66683b22d6bb0b4644f5a40f84d45edf119 (patch) | |
tree | 6447bc34fe7cff931e133db0c2ef13d4ff61a2de /lib/CodeGen/CGExprScalar.cpp | |
parent | 302684c5e2242c350efb3a638cd0ed1de21705e1 (diff) |
Do is-a-pointer checks in terms of LLVM types in
EmitScalarConversion().
- Important for allowing Obj-C void * to id<X> casts and so on.
- Not sure about this fix however, perhaps Type should understand
that id is effectively a pointer type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55311 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index af8fe2779b..963aeaf59c 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -379,9 +379,11 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, if (Src->getType() == DstTy) return Src; - // Handle pointer conversions next: pointers can only be converted to/from - // other pointers and integers. - if (isa<PointerType>(DstType)) { + // Handle pointer conversions next: pointers can only be converted + // to/from other pointers and integers. Check for pointer types in + // terms of LLVM, as some native types (like Obj-C id) may map to a + // pointer type. + if (isa<llvm::PointerType>(DstTy)) { // The source value may be an integer, or a pointer. if (isa<llvm::PointerType>(Src->getType())) return Builder.CreateBitCast(Src, DstTy, "conv"); @@ -389,7 +391,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, return Builder.CreateIntToPtr(Src, DstTy, "conv"); } - if (isa<PointerType>(SrcType)) { + if (isa<llvm::PointerType>(Src->getType())) { // Must be an ptr to int cast. assert(isa<llvm::IntegerType>(DstTy) && "not ptr->int?"); return Builder.CreatePtrToInt(Src, DstTy, "conv"); |