From: Daniel Dunbar Date: Mon, 25 Aug 2008 09:51:32 +0000 (+0000) Subject: Do is-a-pointer checks in terms of LLVM types in X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=270cc66683b22d6bb0b4644f5a40f84d45edf119;p=clang Do is-a-pointer checks in terms of LLVM types in EmitScalarConversion(). - Important for allowing Obj-C void * to id 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 --- 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(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(DstTy)) { // The source value may be an integer, or a pointer. if (isa(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(SrcType)) { + if (isa(Src->getType())) { // Must be an ptr to int cast. assert(isa(DstTy) && "not ptr->int?"); return Builder.CreatePtrToInt(Src, DstTy, "conv");