Skip to content

Commit 7b4ce1d

Browse files
Merge pull request #242 from ds5678/improve-md-node-operands-implementation
Improve MDNode operands implementation
2 parents 4ce5ab2 + 49a14a0 commit 7b4ce1d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sources/LLVMSharp.Interop/Extensions/LLVMValueRef.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public readonly LLVMLinkage Linkage
467467
}
468468
}
469469

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

472472
public readonly string Name
473473
{
@@ -969,19 +969,20 @@ public readonly IEnumerable<LLVMValueRef> GetInstructions()
969969

970970
public readonly LLVMValueRef[] GetMDNodeOperands()
971971
{
972-
if (Kind != LLVMValueKind.LLVMMetadataAsValueValueKind)
972+
uint count = MDNodeOperandsCount;
973+
if (count == 0)
973974
{
974975
return [];
975976
}
976977

977-
var destination = new LLVMValueRef[MDNodeOperandsCount];
978+
var destination = new LLVMValueRef[count];
978979
GetMDNodeOperands(destination);
979980
return destination;
980981
}
981982

982983
public readonly void GetMDNodeOperands(Span<LLVMValueRef> destination)
983984
{
984-
if (Kind != LLVMValueKind.LLVMMetadataAsValueValueKind)
985+
if (IsAMDNode == null)
985986
{
986987
return;
987988
}

0 commit comments

Comments
 (0)