dotnet / LLVMSharp

LLVM bindings for .NET Standard written in C# using ClangSharp
MIT License
844 stars 97 forks source link

Expose AddModuleFlag functionality within LLVMModuleRef #181

Closed ryan-moreno closed 2 years ago

ryan-moreno commented 2 years ago

This PR exposes the LLVMAddModuleFlag and LLVMLinkModules2 functionality within the LLVMModuleRef class. This allows for a more straightforward method for adding module flags using the LLVMSharp API and provides a way to link modules using the LLVMSharp API. It also adds a test to ensure that LLVMAddModuleFlag constructs the correct flag behavior in the outputted debug information.

The addition of the AddModuleFlag functionality also helps to clarify this situation: There are two different ways to add a module flag in LLVM Native: A) using LLVMAddModuleFlag (which expects a 0-based LLVMModuleFlagBehavior) and B) using LLVMAddNamedMetadataOperand (which expects a 1-based behavior represented by a uint). Exposing the AddModuleFlag functionality is meant to ease this confusion by adding a more straightforward method to create module flags that uses the LLVMModuleFlagBehavior enum as expected.

tannergooding commented 2 years ago

Thanks for the contribution!