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 | 427f873196af186b274118b673ea3d3f4226266f (patch) | |
| tree | 419ea57723b23485c1a01fae7f9a4d8d65d6b775 /clang/lib | |
| parent | 81128e04e783a48e7a393b6bd3c8892de353002c (diff) | |
| download | bcm5719-llvm-427f873196af186b274118b673ea3d3f4226266f.tar.gz bcm5719-llvm-427f873196af186b274118b673ea3d3f4226266f.zip | |
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.
llvm-svn: 55311
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index af8fe2779b2..963aeaf59c5 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/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"); |

