Skip to content

Commit

Permalink
Fix LLVMGlobalGetValueType not available in LLVM <= 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Lambein committed Apr 11, 2024
1 parent 3bacdd6 commit a903e0a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/values/global_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ impl<'ctx> GlobalValue<'ctx> {
unsafe { LLVMSetLinkage(self.as_value_ref(), linkage.into()) }
}

#[llvm_versions(8.0..=latest)]
pub fn get_value_type(self) -> AnyTypeEnum<'ctx> {
unsafe { AnyTypeEnum::new(llvm_sys::core::LLVMGlobalGetValueType(self.as_value_ref())) }
}
Expand Down
1 change: 1 addition & 0 deletions tests/all/test_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ fn test_globals() {
assert_eq!(global.get_dll_storage_class(), DLLStorageClass::default());
assert_eq!(global.get_visibility(), GlobalVisibility::default());
assert_eq!(global.get_linkage(), External);
#[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0", feature = "llvm7-0")))]
assert_eq!(global.get_value_type(), AnyTypeEnum::IntType(i8_type));
assert_eq!(module.get_first_global().unwrap(), global);
assert_eq!(module.get_last_global().unwrap(), global);
Expand Down

0 comments on commit a903e0a

Please sign in to comment.