Skip to content

Conversation

@AviAvni
Copy link
Contributor

@AviAvni AviAvni commented Aug 13, 2019

missing apis while porting some of my code from https://www.nuget.org/packages/swigged.llvm/
to LLVMSharp v8

return span.Slice(0, span.IndexOf((byte)'\0')).AsString();
}

public bool EmitToFile(LLVMModuleRef module, string fileName, LLVMCodeGenFileType codegen, out string message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This should be TryEmitToFile and there should optionally be a corresponding string EmitToFile which throws on failure (this follows the .NET Framework design guidelines).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tannergooding Thanks fixed

{
sbyte* pMessage;

int result = LLVM.TargetMachineEmitToFile(this, module, marshaledFileName, codegen, &pMessage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the docs, we need to call LLVMDisposeMessage on errorMessage after marshaling it to managed code. It would probably be good to explicitly call it errorMessage as well, so it is clear to the consumer its intent.

Otherwise, the changes LGTM. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tannergooding thanks fixed

@tannergooding tannergooding merged commit f986236 into dotnet:master Aug 19, 2019
@tannergooding
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants