1
Fork 0

Replaces some instances of as *[const | mut] _ with .cast()

This commit is contained in:
memoryruins 2019-10-05 03:48:14 -04:00
parent 2daa404e9a
commit 173958ac80
8 changed files with 24 additions and 24 deletions

View file

@ -68,7 +68,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut ModuleLlvm, kind: Alloc
let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, let llbb = llvm::LLVMAppendBasicBlockInContext(llcx,
llfn, llfn,
"entry\0".as_ptr() as *const _); "entry\0".as_ptr().cast());
let llbuilder = llvm::LLVMCreateBuilderInContext(llcx); let llbuilder = llvm::LLVMCreateBuilderInContext(llcx);
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb); llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);
@ -80,7 +80,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut ModuleLlvm, kind: Alloc
args.as_ptr(), args.as_ptr(),
args.len() as c_uint, args.len() as c_uint,
None, None,
"\0".as_ptr() as *const _); "\0".as_ptr().cast());
llvm::LLVMSetTailCall(ret, True); llvm::LLVMSetTailCall(ret, True);
if output.is_some() { if output.is_some() {
llvm::LLVMBuildRet(llbuilder, ret); llvm::LLVMBuildRet(llbuilder, ret);

View file

@ -546,7 +546,7 @@ pub(crate) fn run_pass_manager(cgcx: &CodegenContext<LlvmCodegenBackend>,
llvm::LLVMRustAddAnalysisPasses(module.module_llvm.tm, pm, module.module_llvm.llmod()); llvm::LLVMRustAddAnalysisPasses(module.module_llvm.tm, pm, module.module_llvm.llmod());
if config.verify_llvm_ir { if config.verify_llvm_ir {
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _); let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr().cast());
llvm::LLVMRustAddPass(pm, pass.unwrap()); llvm::LLVMRustAddPass(pm, pass.unwrap());
} }
@ -581,12 +581,12 @@ pub(crate) fn run_pass_manager(cgcx: &CodegenContext<LlvmCodegenBackend>,
// We always generate bitcode through ThinLTOBuffers, // We always generate bitcode through ThinLTOBuffers,
// which do not support anonymous globals // which do not support anonymous globals
if config.bitcode_needed() { if config.bitcode_needed() {
let pass = llvm::LLVMRustFindAndCreatePass("name-anon-globals\0".as_ptr() as *const _); let pass = llvm::LLVMRustFindAndCreatePass("name-anon-globals\0".as_ptr().cast());
llvm::LLVMRustAddPass(pm, pass.unwrap()); llvm::LLVMRustAddPass(pm, pass.unwrap());
} }
if config.verify_llvm_ir { if config.verify_llvm_ir {
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _); let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr().cast());
llvm::LLVMRustAddPass(pm, pass.unwrap()); llvm::LLVMRustAddPass(pm, pass.unwrap());
} }

View file

@ -221,8 +221,8 @@ impl<'a> DiagnosticHandlers<'a> {
llcx: &'a llvm::Context) -> Self { llcx: &'a llvm::Context) -> Self {
let data = Box::into_raw(Box::new((cgcx, handler))); let data = Box::into_raw(Box::new((cgcx, handler)));
unsafe { unsafe {
llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data as *mut _); llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data.cast());
llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data as *mut _); llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data.cast());
} }
DiagnosticHandlers { data, llcx } DiagnosticHandlers { data, llcx }
} }
@ -672,7 +672,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext<LlvmCodegenBackend>,
let llglobal = llvm::LLVMAddGlobal( let llglobal = llvm::LLVMAddGlobal(
llmod, llmod,
common::val_ty(llconst), common::val_ty(llconst),
"rustc.embedded.module\0".as_ptr() as *const _, "rustc.embedded.module\0".as_ptr().cast(),
); );
llvm::LLVMSetInitializer(llglobal, llconst); llvm::LLVMSetInitializer(llglobal, llconst);
@ -684,7 +684,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext<LlvmCodegenBackend>,
} else { } else {
".llvmbc\0" ".llvmbc\0"
}; };
llvm::LLVMSetSection(llglobal, section.as_ptr() as *const _); llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage); llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
llvm::LLVMSetGlobalConstant(llglobal, llvm::True); llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
@ -692,7 +692,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext<LlvmCodegenBackend>,
let llglobal = llvm::LLVMAddGlobal( let llglobal = llvm::LLVMAddGlobal(
llmod, llmod,
common::val_ty(llconst), common::val_ty(llconst),
"rustc.embedded.cmdline\0".as_ptr() as *const _, "rustc.embedded.cmdline\0".as_ptr().cast(),
); );
llvm::LLVMSetInitializer(llglobal, llconst); llvm::LLVMSetInitializer(llglobal, llconst);
let section = if is_apple { let section = if is_apple {
@ -700,7 +700,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext<LlvmCodegenBackend>,
} else { } else {
".llvmcmd\0" ".llvmcmd\0"
}; };
llvm::LLVMSetSection(llglobal, section.as_ptr() as *const _); llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage); llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
} }
@ -842,7 +842,7 @@ fn create_msvc_imps(
for (imp_name, val) in globals { for (imp_name, val) in globals {
let imp = llvm::LLVMAddGlobal(llmod, let imp = llvm::LLVMAddGlobal(llmod,
i8p_ty, i8p_ty,
imp_name.as_ptr() as *const _); imp_name.as_ptr().cast());
llvm::LLVMSetInitializer(imp, consts::ptrcast(val, i8p_ty)); llvm::LLVMSetInitializer(imp, consts::ptrcast(val, i8p_ty));
llvm::LLVMRustSetLinkage(imp, llvm::Linkage::ExternalLinkage); llvm::LLVMRustSetLinkage(imp, llvm::Linkage::ExternalLinkage);
} }

View file

@ -488,7 +488,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
if let Some(section) = attrs.link_section { if let Some(section) = attrs.link_section {
let section = llvm::LLVMMDStringInContext( let section = llvm::LLVMMDStringInContext(
self.llcx, self.llcx,
section.as_str().as_ptr() as *const _, section.as_str().as_ptr().cast(),
section.as_str().len() as c_uint, section.as_str().len() as c_uint,
); );
assert!(alloc.relocations().is_empty()); assert!(alloc.relocations().is_empty());
@ -500,14 +500,14 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
0..alloc.len()); 0..alloc.len());
let alloc = llvm::LLVMMDStringInContext( let alloc = llvm::LLVMMDStringInContext(
self.llcx, self.llcx,
bytes.as_ptr() as *const _, bytes.as_ptr().cast(),
bytes.len() as c_uint, bytes.len() as c_uint,
); );
let data = [section, alloc]; let data = [section, alloc];
let meta = llvm::LLVMMDNodeInContext(self.llcx, data.as_ptr(), 2); let meta = llvm::LLVMMDNodeInContext(self.llcx, data.as_ptr(), 2);
llvm::LLVMAddNamedMetadataOperand( llvm::LLVMAddNamedMetadataOperand(
self.llmod, self.llmod,
"wasm.custom_sections\0".as_ptr() as *const _, "wasm.custom_sections\0".as_ptr().cast(),
meta, meta,
); );
} }

View file

@ -211,7 +211,7 @@ pub unsafe fn create_module(
// If skipping the PLT is enabled, we need to add some module metadata // If skipping the PLT is enabled, we need to add some module metadata
// to ensure intrinsic calls don't use it. // to ensure intrinsic calls don't use it.
if !sess.needs_plt() { if !sess.needs_plt() {
let avoid_plt = "RtLibUseGOT\0".as_ptr() as *const _; let avoid_plt = "RtLibUseGOT\0".as_ptr().cast();
llvm::LLVMRustAddModuleFlag(llmod, avoid_plt, 1); llvm::LLVMRustAddModuleFlag(llmod, avoid_plt, 1);
} }

View file

@ -37,7 +37,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>)
let section_var = unsafe { let section_var = unsafe {
llvm::LLVMGetNamedGlobal(cx.llmod, llvm::LLVMGetNamedGlobal(cx.llmod,
c_section_var_name.as_ptr() as *const _) c_section_var_name.as_ptr().cast())
}; };
section_var.unwrap_or_else(|| { section_var.unwrap_or_else(|| {
@ -52,7 +52,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>)
llvm_type).unwrap_or_else(||{ llvm_type).unwrap_or_else(||{
bug!("symbol `{}` is already defined", section_var_name) bug!("symbol `{}` is already defined", section_var_name)
}); });
llvm::LLVMSetSection(section_var, section_name.as_ptr() as *const _); llvm::LLVMSetSection(section_var, section_name.as_ptr().cast());
llvm::LLVMSetInitializer(section_var, cx.const_bytes(section_contents)); llvm::LLVMSetInitializer(section_var, cx.const_bytes(section_contents));
llvm::LLVMSetGlobalConstant(section_var, llvm::True); llvm::LLVMSetGlobalConstant(section_var, llvm::True);
llvm::LLVMSetUnnamedAddr(section_var, llvm::True); llvm::LLVMSetUnnamedAddr(section_var, llvm::True);

View file

@ -960,9 +960,9 @@ pub fn compile_unit_metadata(
file_metadata, file_metadata,
producer.as_ptr(), producer.as_ptr(),
tcx.sess.opts.optimize != config::OptLevel::No, tcx.sess.opts.optimize != config::OptLevel::No,
flags.as_ptr() as *const _, flags.as_ptr().cast(),
0, 0,
split_name.as_ptr() as *const _, split_name.as_ptr().cast(),
kind); kind);
if tcx.sess.opts.debugging_opts.profile { if tcx.sess.opts.debugging_opts.profile {
@ -991,7 +991,7 @@ pub fn compile_unit_metadata(
if tcx.sess.opts.target_triple.triple().starts_with("wasm32") { if tcx.sess.opts.target_triple.triple().starts_with("wasm32") {
let name_metadata = llvm::LLVMMDStringInContext( let name_metadata = llvm::LLVMMDStringInContext(
debug_context.llcontext, debug_context.llcontext,
rustc_producer.as_ptr() as *const _, rustc_producer.as_ptr().cast(),
rustc_producer.as_bytes().len() as c_uint, rustc_producer.as_bytes().len() as c_uint,
); );
llvm::LLVMAddNamedMetadataOperand( llvm::LLVMAddNamedMetadataOperand(

View file

@ -127,20 +127,20 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
if cx.sess().target.target.options.is_like_osx || if cx.sess().target.target.options.is_like_osx ||
cx.sess().target.target.options.is_like_android { cx.sess().target.target.options.is_like_android {
llvm::LLVMRustAddModuleFlag(cx.llmod, llvm::LLVMRustAddModuleFlag(cx.llmod,
"Dwarf Version\0".as_ptr() as *const _, "Dwarf Version\0".as_ptr().cast(),
2) 2)
} }
// Indicate that we want CodeView debug information on MSVC // Indicate that we want CodeView debug information on MSVC
if cx.sess().target.target.options.is_like_msvc { if cx.sess().target.target.options.is_like_msvc {
llvm::LLVMRustAddModuleFlag(cx.llmod, llvm::LLVMRustAddModuleFlag(cx.llmod,
"CodeView\0".as_ptr() as *const _, "CodeView\0".as_ptr().cast(),
1) 1)
} }
// Prevent bitcode readers from deleting the debug info. // Prevent bitcode readers from deleting the debug info.
let ptr = "Debug Info Version\0".as_ptr(); let ptr = "Debug Info Version\0".as_ptr();
llvm::LLVMRustAddModuleFlag(cx.llmod, ptr as *const _, llvm::LLVMRustAddModuleFlag(cx.llmod, ptr.cast(),
llvm::LLVMRustDebugMetadataVersion()); llvm::LLVMRustDebugMetadataVersion());
}; };
} }