From c04aea01588a98b6917056a5e7e773896657788b Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 17 Apr 2020 14:59:16 -0700 Subject: [PATCH] Ensure that LLVMTypeRef passes parameters down properly --- Tests/LLVMSharp.UnitTests/Functions.cs | 19 +++++++++++++++++++ .../Interop.Extensions/LLVMTypeRef.cs | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 Tests/LLVMSharp.UnitTests/Functions.cs diff --git a/Tests/LLVMSharp.UnitTests/Functions.cs b/Tests/LLVMSharp.UnitTests/Functions.cs new file mode 100644 index 00000000..630268a6 --- /dev/null +++ b/Tests/LLVMSharp.UnitTests/Functions.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using LLVMSharp.Interop; +using NUnit.Framework; + +namespace LLVMSharp.UnitTests +{ + public class Functions + { + [Test] + public void ParamTypesRoundtrip() + { + var returnType = LLVMTypeRef.Int8; + var parameterTypes = new[] { LLVMTypeRef.Double }; + var functionType = LLVMTypeRef.CreateFunction(returnType, parameterTypes); + Assert.AreEqual(parameterTypes, functionType.ParamTypes); + } + } +} diff --git a/sources/LLVMSharp/Interop.Extensions/LLVMTypeRef.cs b/sources/LLVMSharp/Interop.Extensions/LLVMTypeRef.cs index d9be1f18..3608e0ae 100644 --- a/sources/LLVMSharp/Interop.Extensions/LLVMTypeRef.cs +++ b/sources/LLVMSharp/Interop.Extensions/LLVMTypeRef.cs @@ -84,7 +84,7 @@ public LLVMTypeRef[] ParamTypes fixed (LLVMTypeRef* pDest = Dest) { - LLVM.GetParamTypes(this, (LLVMOpaqueType**)&pDest); + LLVM.GetParamTypes(this, (LLVMOpaqueType**)pDest); } return Dest; @@ -112,7 +112,7 @@ public LLVMTypeRef[] StructElementTypes fixed (LLVMTypeRef* pDest = Dest) { - LLVM.GetStructElementTypes(this, (LLVMOpaqueType**)&pDest); + LLVM.GetStructElementTypes(this, (LLVMOpaqueType**)pDest); } return Dest; @@ -155,7 +155,7 @@ public LLVMTypeRef[] Subtypes fixed (LLVMTypeRef* pArr = Arr) { - LLVM.GetSubtypes(this, (LLVMOpaqueType**)&pArr); + LLVM.GetSubtypes(this, (LLVMOpaqueType**)pArr); } return Arr;