Add warn(unreachable_pub) to rustc_codegen_llvm.

This commit is contained in:
Nicholas Nethercote 2024-07-06 22:26:42 +10:00
parent 0544d3a952
commit 61627438eb
31 changed files with 206 additions and 184 deletions

View file

@ -32,7 +32,7 @@ use crate::context::CodegenCx;
use crate::value::Value;
use crate::{attributes, llvm};
pub struct ValueIter<'ll> {
pub(crate) struct ValueIter<'ll> {
cur: Option<&'ll Value>,
step: unsafe extern "C" fn(&'ll Value) -> Option<&'ll Value>,
}
@ -49,11 +49,14 @@ impl<'ll> Iterator for ValueIter<'ll> {
}
}
pub fn iter_globals(llmod: &llvm::Module) -> ValueIter<'_> {
pub(crate) fn iter_globals(llmod: &llvm::Module) -> ValueIter<'_> {
unsafe { ValueIter { cur: llvm::LLVMGetFirstGlobal(llmod), step: llvm::LLVMGetNextGlobal } }
}
pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen<ModuleLlvm>, u64) {
pub(crate) fn compile_codegen_unit(
tcx: TyCtxt<'_>,
cgu_name: Symbol,
) -> (ModuleCodegen<ModuleLlvm>, u64) {
let start_time = Instant::now();
let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx);
@ -140,7 +143,7 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen
(module, cost)
}
pub fn set_link_section(llval: &Value, attrs: &CodegenFnAttrs) {
pub(crate) fn set_link_section(llval: &Value, attrs: &CodegenFnAttrs) {
let Some(sect) = attrs.link_section else { return };
unsafe {
let buf = SmallCStr::new(sect.as_str());
@ -148,7 +151,7 @@ pub fn set_link_section(llval: &Value, attrs: &CodegenFnAttrs) {
}
}
pub fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage {
pub(crate) fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage {
match linkage {
Linkage::External => llvm::Linkage::ExternalLinkage,
Linkage::AvailableExternally => llvm::Linkage::AvailableExternallyLinkage,
@ -164,7 +167,7 @@ pub fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage {
}
}
pub fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
pub(crate) fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
match linkage {
Visibility::Default => llvm::Visibility::Default,
Visibility::Hidden => llvm::Visibility::Hidden,