Skip to content

Commit 49a14a0

Browse files
committed
Improve MDNode operands implementation
1 parent 5e4623f commit 49a14a0

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

sources/LLVMSharp.Interop/Extensions/LLVMValueRef.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public readonly LLVMLinkage Linkage
459459
}
460460
}
461461

462-
public readonly uint MDNodeOperandsCount => (Kind == LLVMValueKind.LLVMMetadataAsValueValueKind) ? LLVM.GetMDNodeNumOperands(this) : default;
462+
public readonly uint MDNodeOperandsCount => (IsAMDNode == null) ? LLVM.GetMDNodeNumOperands(this) : default;
463463

464464
public readonly string Name
465465
{
@@ -895,19 +895,20 @@ public readonly void GetBasicBlocks(Span<LLVMBasicBlockRef> destination)
895895

896896
public readonly LLVMValueRef[] GetMDNodeOperands()
897897
{
898-
if (Kind != LLVMValueKind.LLVMMetadataAsValueValueKind)
898+
uint count = MDNodeOperandsCount;
899+
if (count == 0)
899900
{
900901
return [];
901902
}
902903

903-
var destination = new LLVMValueRef[MDNodeOperandsCount];
904+
var destination = new LLVMValueRef[count];
904905
GetMDNodeOperands(destination);
905906
return destination;
906907
}
907908

908909
public readonly void GetMDNodeOperands(Span<LLVMValueRef> destination)
909910
{
910-
if (Kind != LLVMValueKind.LLVMMetadataAsValueValueKind)
911+
if (IsAMDNode == null)
911912
{
912913
return;
913914
}

0 commit comments

Comments
 (0)