diff --git a/clang/CodeGen/CGExprScalar.cpp b/clang/CodeGen/CGExprScalar.cpp index dd3c2ed7f025..62b223f0eea4 100644 --- a/clang/CodeGen/CGExprScalar.cpp +++ b/clang/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/clang/test/CodeGen/pointer-to-int.c b/clang/test/CodeGen/pointer-to-int.c new file mode 100644 index 000000000000..7599e0d4abea --- /dev/null +++ b/clang/test/CodeGen/pointer-to-int.c @@ -0,0 +1,6 @@ +// RUN: clang -emit-llvm %s + +int test(void* i) +{ + return (int)i; +}