]> granicus.if.org Git - clang/commitdiff
Fix a typo that prevented pointer-to-int conversions from working.
authorAnders Carlsson <andersca@mac.com>
Wed, 31 Oct 2007 23:18:02 +0000 (23:18 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 31 Oct 2007 23:18:02 +0000 (23:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43588 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CGExprScalar.cpp
test/CodeGen/pointer-to-int.c [new file with mode: 0644]

index dd3c2ed7f025e9502fea22943a778fb29c20dffa..62b223f0eea4e95eb5c6356ec568052ada41422b 100644 (file)
@@ -334,7 +334,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
   if (isa<PointerType>(SrcType)) {
     // Must be an ptr to int cast.
     assert(isa<llvm::IntegerType>(DstTy) && "not ptr->int?");
-    return Builder.CreateIntToPtr(Src, DstTy, "conv");
+    return Builder.CreatePtrToInt(Src, DstTy, "conv");
   }
   
   // Finally, we have the arithmetic types: real int/float.
diff --git a/test/CodeGen/pointer-to-int.c b/test/CodeGen/pointer-to-int.c
new file mode 100644 (file)
index 0000000..7599e0d
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: clang -emit-llvm %s
+
+int test(void* i)
+{
+  return (int)i;
+}