]> granicus.if.org Git - clang/commitdiff
Do is-a-pointer checks in terms of LLVM types in
authorDaniel Dunbar <daniel@zuster.org>
Mon, 25 Aug 2008 09:51:32 +0000 (09:51 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 25 Aug 2008 09:51:32 +0000 (09:51 +0000)
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

lib/CodeGen/CGExprScalar.cpp

index af8fe2779b214460877b3cebf3dbc9732702d794..963aeaf59c5cdf09d9fdf3d493798ef04f62c69a 100644 (file)
@@ -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");