Skip to content

Commit a959d0a

Browse files
committed
Fix compile errors and add missing API content
1 parent df607a1 commit a959d0a

8 files changed

Lines changed: 530 additions & 119 deletions

File tree

sources/LLVMSharp.Interop/Extensions/LLVM.Manual.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,46 @@
33
// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-20.1.2/llvm/include/llvm-c
44
// Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information.
55

6+
using System;
67
using System.Runtime.InteropServices;
78

89
namespace LLVMSharp.Interop;
910

1011
public static unsafe partial class LLVM
1112
{
13+
public static string DIFileGetDirectory(LLVMMetadataRef file)
14+
{
15+
uint length = 0;
16+
sbyte* directory = DIFileGetDirectory(file, &length);
17+
if (directory == null)
18+
{
19+
return "";
20+
}
21+
return new ReadOnlySpan<byte>(directory, (int)length).AsString();
22+
}
23+
24+
public static string DIFileGetFilename(LLVMMetadataRef file)
25+
{
26+
uint length = 0;
27+
sbyte* filename = DIFileGetFilename(file, &length);
28+
if (filename == null)
29+
{
30+
return "";
31+
}
32+
return new ReadOnlySpan<byte>(filename, (int)length).AsString();
33+
}
34+
35+
public static string DITypeGetName(LLVMMetadataRef type)
36+
{
37+
nuint length = 0;
38+
sbyte* name = DITypeGetName(type, &length);
39+
if (name == null)
40+
{
41+
return "";
42+
}
43+
return new ReadOnlySpan<byte>(name, (int)length).AsString();
44+
}
45+
1246
[DllImport("libLLVM", CallingConvention = CallingConvention.Cdecl, EntryPoint = "LLVMInitializeAArch64TargetInfo", ExactSpelling = true)]
1347
public static extern void InitializeAArch64TargetInfo();
1448

0 commit comments

Comments
 (0)