mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Split AllocatorKind::fn_name in global_fn_name and default_fn_name
This commit is contained in:
parent
4ce20663f7
commit
6ba7c5db07
@ -6,13 +6,12 @@ pub enum AllocatorKind {
|
||||
Default,
|
||||
}
|
||||
|
||||
impl AllocatorKind {
|
||||
pub fn fn_name(&self, base: Symbol) -> String {
|
||||
match *self {
|
||||
AllocatorKind::Global => format!("__rust_{base}"),
|
||||
AllocatorKind::Default => format!("__rdl_{base}"),
|
||||
}
|
||||
}
|
||||
pub fn global_fn_name(base: Symbol) -> String {
|
||||
format!("__rust_{base}")
|
||||
}
|
||||
|
||||
pub fn default_fn_name(base: Symbol) -> String {
|
||||
format!("__rdl_{base}")
|
||||
}
|
||||
|
||||
pub fn alloc_error_handler_name(alloc_error_handler_kind: AllocatorKind) -> &'static str {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::util::check_builtin_macro_attribute;
|
||||
|
||||
use rustc_ast::expand::allocator::{
|
||||
AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS,
|
||||
global_fn_name, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS,
|
||||
};
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::{self as ast, AttrVec, Expr, FnHeader, FnSig, Generics, Param, StmtKind};
|
||||
@ -90,7 +90,7 @@ impl AllocFnFactory<'_, '_> {
|
||||
}));
|
||||
let item = self.cx.item(
|
||||
self.span,
|
||||
Ident::from_str_and_span(&AllocatorKind::Global.fn_name(method.name), self.span),
|
||||
Ident::from_str_and_span(&global_fn_name(method.name), self.span),
|
||||
self.attrs(),
|
||||
kind,
|
||||
);
|
||||
|
@ -4,7 +4,7 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
use rustc_ast::expand::allocator::{
|
||||
alloc_error_handler_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS,
|
||||
alloc_error_handler_name, default_fn_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS,
|
||||
};
|
||||
use rustc_codegen_ssa::base::allocator_kind_for_codegen;
|
||||
use rustc_session::config::OomStrategy;
|
||||
@ -69,7 +69,7 @@ fn codegen_inner(
|
||||
unwind_context,
|
||||
sig,
|
||||
&format!("__rust_{}", method.name),
|
||||
&AllocatorKind::Default.fn_name(method.name),
|
||||
&default_fn_name(method.name),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
use gccjit::FnAttribute;
|
||||
use gccjit::{FunctionType, GlobalKind, ToRValue};
|
||||
use rustc_ast::expand::allocator::{
|
||||
alloc_error_handler_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS,
|
||||
alloc_error_handler_name, default_fn_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS,
|
||||
};
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
@ -61,7 +61,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
|
||||
// TODO(antoyo): emit unwind tables.
|
||||
}
|
||||
|
||||
let callee = AllocatorKind::Default.fn_name(method.name);
|
||||
let callee = default_fn_name(method.name);
|
||||
let args: Vec<_> = types.iter().enumerate()
|
||||
.map(|(index, typ)| context.new_parameter(None, *typ, &format!("param{}", index)))
|
||||
.collect();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::attributes;
|
||||
use libc::c_uint;
|
||||
use rustc_ast::expand::allocator::{
|
||||
alloc_error_handler_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS,
|
||||
alloc_error_handler_name, default_fn_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS,
|
||||
};
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
@ -71,7 +71,7 @@ pub(crate) unsafe fn codegen(
|
||||
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &[uwtable]);
|
||||
}
|
||||
|
||||
let callee = AllocatorKind::Default.fn_name(method.name);
|
||||
let callee = default_fn_name(method.name);
|
||||
let callee =
|
||||
llvm::LLVMRustGetOrInsertFunction(llmod, callee.as_ptr().cast(), callee.len(), ty);
|
||||
llvm::LLVMRustSetVisibility(callee, llvm::Visibility::Hidden);
|
||||
|
@ -4,7 +4,7 @@ use crate::errors;
|
||||
use crate::locator::{CrateError, CrateLocator, CratePaths};
|
||||
use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob};
|
||||
|
||||
use rustc_ast::expand::allocator::AllocatorKind;
|
||||
use rustc_ast::expand::allocator::{alloc_error_handler_name, global_fn_name, AllocatorKind};
|
||||
use rustc_ast::{self as ast, *};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
@ -1044,7 +1044,7 @@ fn global_allocator_spans(krate: &ast::Crate) -> Vec<Span> {
|
||||
}
|
||||
}
|
||||
|
||||
let name = Symbol::intern(&AllocatorKind::Global.fn_name(sym::alloc));
|
||||
let name = Symbol::intern(&global_fn_name(sym::alloc));
|
||||
let mut f = Finder { name, spans: Vec::new() };
|
||||
visit::walk_crate(&mut f, krate);
|
||||
f.spans
|
||||
@ -1066,7 +1066,7 @@ fn alloc_error_handler_spans(krate: &ast::Crate) -> Vec<Span> {
|
||||
}
|
||||
}
|
||||
|
||||
let name = Symbol::intern(&AllocatorKind::Global.fn_name(sym::oom));
|
||||
let name = Symbol::intern(alloc_error_handler_name(AllocatorKind::Global));
|
||||
let mut f = Finder { name, spans: Vec::new() };
|
||||
visit::walk_crate(&mut f, krate);
|
||||
f.spans
|
||||
|
Loading…
Reference in New Issue
Block a user