From 50b5a30db40322880340e957ad7d6d8d60bb4c5b Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 31 Oct 2007 23:18:02 +0000 Subject: [PATCH] Fix a typo that prevented pointer-to-int conversions from working. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43588 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CGExprScalar.cpp | 2 +- test/CodeGen/pointer-to-int.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/pointer-to-int.c diff --git a/CodeGen/CGExprScalar.cpp b/CodeGen/CGExprScalar.cpp index dd3c2ed7f0..62b223f0ee 100644 --- a/CodeGen/CGExprScalar.cpp +++ b/CodeGen/CGExprScalar.cpp @@ -334,7 +334,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, if (isa(SrcType)) { // Must be an ptr to int cast. assert(isa(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 index 0000000000..7599e0d4ab --- /dev/null +++ b/test/CodeGen/pointer-to-int.c @@ -0,0 +1,6 @@ +// RUN: clang -emit-llvm %s + +int test(void* i) +{ + return (int)i; +} -- 2.40.0