-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide LLVMTypeWrapper
trait
#223
base: main
Are you sure you want to change the base?
Conversation
It isn't being used anywhere (aside from `push` and immediate `pop`) and has no impact on the visitor algorithm.
Instead of keeping raw pointer fields (of types like `LLVMValueRef`, `LLVMMetadataRef`) public and defining constructors with different names, provide the `LLVMTypeWrapper` trait with `from_ptr()` `as_ptr()` method for all of them. This will allow to convert all safe wrappers from and to raw pointers with one method, which is going to be helpful for building macros for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @vadorovsky)
src/llvm/types/di.rs
line 54 at r2 (raw file):
type Target = LLVMMetadataRef; /// Constructs a new [`DIFile`] from the given `metadata`.
looks like this comment should go on the trait now.
src/llvm/types/di.rs
line 131 at r2 (raw file):
type Target = LLVMValueRef; /// Constructs a new [`DIType`] from the given `value`.
looks like this comment should go on the trait now.
src/llvm/types/di.rs
line 190 at r2 (raw file):
type Target = LLVMValueRef; /// Constructs a new [`DIDerivedType`] from the given `value`.
looks like this comment should go on the trait now.
src/llvm/types/di.rs
line 259 at r2 (raw file):
type Target = LLVMValueRef; /// Constructs a new [`DICompositeType`] from the given `value`.
looks like this comment should go on the trait now.
src/llvm/types/di.rs
line 369 at r2 (raw file):
type Target = LLVMValueRef; /// Constructs a new [`DISubprogram`] from the given `value`.
looks like this comment should go on the trait now.
src/llvm/types/ir.rs
line 214 at r2 (raw file):
type Target = LLVMValueRef; /// Constructs a new [`MDNode`] from the given `value`.
looks like this comment should go on the trait now.
src/llvm/types/ir.rs
line 221 at r2 (raw file):
/// instance of [LLVM `MDNode`](https://llvm.org/doxygen/classllvm_1_1MDNode.html). /// It's the caller's responsibility to ensure this invariant, as this /// method doesn't perform any valiation checks.
"valiation" typo throughout
src/llvm/types/ir.rs
line 243 at r2 (raw file):
/// It's the caller's responsibility to ensure this invariant, as this /// method doesn't perform any validation checks. pub(crate) unsafe fn from_metadata_ref(
could we just inline this method?
src/llvm/types/ir.rs
line 251 at r2 (raw file):
/// Constructs an empty metadata node. /// Constructs a new [`MDNode`] from the given `value`.
detritus
src/llvm/types/ir.rs
line 333 at r2 (raw file):
type Target = LLVMValueRef; /// Constructs a new [`Function`] from the given `value`.
looks like this comment should go on the trait now.
src/llvm/types/mod.rs
line 7 at r2 (raw file):
type Target: ?Sized; unsafe fn from_ptr(ptr: Self::Target) -> Self;
why is it unsafe?
Previously, tamird (Tamir Duberstein) wrote…
The most of pointer types coming from LLVM-C API (through llvm-sys) are more vague than the C++ ones. There is But good that you asked. I didn't think about it before, but there are functions like |
Instead of keeping raw pointer fields (of types like
LLVMValueRef
,LLVMMetadataRef
) public and defining constructors with different names, provide theLLVMTypeWrapper
trait withfrom_ptr()
as_ptr()
method for all of them.This will allow to convert all safe wrappers from and to raw pointers with one method, which is going to be helpful for building macros for them.
Depends on #222
This change is