qsharp-compiler
qsharp-compiler copied to clipboard
Consider inheriting from `SafeHandle` in LlvmBindings native handle wrappers
Several classes in LlvmBindings act as wrappers around native handles that need to be cleaned up by specific native calls on dispose of their wrappers. To get predictable behavior for closing the native handles on exceptions and the like, it is usually recommended to inherit from the SafeHandle class and use it's patterns for management of handles. While the existing manual dispose pattern hasn't caused any problems yet (and matches the code in LLVMSharp we copied this from), it would be good to follow the language recommendation.
So far we've noted the manual handle management in LLVMBuilderRef
, LLVMContextRef
, LLVMModuleRef
, and the newly added LLVMExecutionEngineRef
.