Skip to content

Commit 0acab90

Browse files
Ensure that LLVMTypeRef passes parameters down properly (#135)
1 parent a73a07d commit 0acab90

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// 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.
2+
3+
using LLVMSharp.Interop;
4+
using NUnit.Framework;
5+
6+
namespace LLVMSharp.UnitTests
7+
{
8+
public class Functions
9+
{
10+
[Test]
11+
public void ParamTypesRoundtrip()
12+
{
13+
var returnType = LLVMTypeRef.Int8;
14+
var parameterTypes = new[] { LLVMTypeRef.Double };
15+
var functionType = LLVMTypeRef.CreateFunction(returnType, parameterTypes);
16+
Assert.AreEqual(parameterTypes, functionType.ParamTypes);
17+
}
18+
}
19+
}

sources/LLVMSharp/Interop.Extensions/LLVMTypeRef.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public LLVMTypeRef[] ParamTypes
8484

8585
fixed (LLVMTypeRef* pDest = Dest)
8686
{
87-
LLVM.GetParamTypes(this, (LLVMOpaqueType**)&pDest);
87+
LLVM.GetParamTypes(this, (LLVMOpaqueType**)pDest);
8888
}
8989

9090
return Dest;
@@ -112,7 +112,7 @@ public LLVMTypeRef[] StructElementTypes
112112

113113
fixed (LLVMTypeRef* pDest = Dest)
114114
{
115-
LLVM.GetStructElementTypes(this, (LLVMOpaqueType**)&pDest);
115+
LLVM.GetStructElementTypes(this, (LLVMOpaqueType**)pDest);
116116
}
117117

118118
return Dest;
@@ -155,7 +155,7 @@ public LLVMTypeRef[] Subtypes
155155

156156
fixed (LLVMTypeRef* pArr = Arr)
157157
{
158-
LLVM.GetSubtypes(this, (LLVMOpaqueType**)&pArr);
158+
LLVM.GetSubtypes(this, (LLVMOpaqueType**)pArr);
159159
}
160160

161161
return Arr;

0 commit comments

Comments
 (0)