[cfe-commits] r55311 - /cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Daniel Dunbar daniel at zuster.org
Mon Aug 25 02:51:32 PDT 2008


Author: ddunbar
Date: Mon Aug 25 04:51:32 2008
New Revision: 55311

URL: http://llvm.org/viewvc/llvm-project?rev=55311&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=55311&r1=55310&r2=55311&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Aug 25 04:51:32 2008
@@ -379,9 +379,11 @@
   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 @@
     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");





More information about the cfe-commits mailing list