Remove LocalInternedString
uses from librustc_codegen_llvm
.
This commit is contained in:
parent
b50db34e4d
commit
d78b33a807
5 changed files with 20 additions and 20 deletions
|
@ -5,7 +5,6 @@ use crate::context::CodegenCx;
|
||||||
use crate::type_::Type;
|
use crate::type_::Type;
|
||||||
use crate::type_of::LayoutLlvmExt;
|
use crate::type_of::LayoutLlvmExt;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use syntax::symbol::LocalInternedString;
|
|
||||||
use rustc_codegen_ssa::common::{IntPredicate, TypeKind, RealPredicate};
|
use rustc_codegen_ssa::common::{IntPredicate, TypeKind, RealPredicate};
|
||||||
use rustc_codegen_ssa::MemFlags;
|
use rustc_codegen_ssa::MemFlags;
|
||||||
use libc::{c_uint, c_char};
|
use libc::{c_uint, c_char};
|
||||||
|
@ -24,6 +23,7 @@ use std::ffi::CStr;
|
||||||
use std::ops::{Deref, Range};
|
use std::ops::{Deref, Range};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::iter::TrustedLen;
|
use std::iter::TrustedLen;
|
||||||
|
use syntax::symbol::Symbol;
|
||||||
|
|
||||||
// All Builders must have an llfn associated with them
|
// All Builders must have an llfn associated with them
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
@ -1082,8 +1082,8 @@ impl StaticBuilderMethods for Builder<'a, 'll, 'tcx> {
|
||||||
|
|
||||||
fn static_panic_msg(
|
fn static_panic_msg(
|
||||||
&mut self,
|
&mut self,
|
||||||
msg: Option<LocalInternedString>,
|
msg: Option<Symbol>,
|
||||||
filename: LocalInternedString,
|
filename: Symbol,
|
||||||
line: Self::Value,
|
line: Self::Value,
|
||||||
col: Self::Value,
|
col: Self::Value,
|
||||||
kind: &str,
|
kind: &str,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||||
|
|
||||||
use libc::{c_uint, c_char};
|
use libc::{c_uint, c_char};
|
||||||
|
|
||||||
use syntax::symbol::LocalInternedString;
|
use syntax::symbol::Symbol;
|
||||||
use syntax::ast::Mutability;
|
use syntax::ast::Mutability;
|
||||||
|
|
||||||
pub use crate::context::CodegenCx;
|
pub use crate::context::CodegenCx;
|
||||||
|
@ -122,7 +122,7 @@ impl CodegenCx<'ll, 'tcx> {
|
||||||
|
|
||||||
fn const_cstr(
|
fn const_cstr(
|
||||||
&self,
|
&self,
|
||||||
s: LocalInternedString,
|
s: Symbol,
|
||||||
null_terminated: bool,
|
null_terminated: bool,
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -130,9 +130,10 @@ impl CodegenCx<'ll, 'tcx> {
|
||||||
return llval;
|
return llval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let s_str = s.as_str();
|
||||||
let sc = llvm::LLVMConstStringInContext(self.llcx,
|
let sc = llvm::LLVMConstStringInContext(self.llcx,
|
||||||
s.as_ptr() as *const c_char,
|
s_str.as_ptr() as *const c_char,
|
||||||
s.len() as c_uint,
|
s_str.len() as c_uint,
|
||||||
!null_terminated as Bool);
|
!null_terminated as Bool);
|
||||||
let sym = self.generate_local_symbol_name("str");
|
let sym = self.generate_local_symbol_name("str");
|
||||||
let g = self.define_global(&sym[..], self.val_ty(sc)).unwrap_or_else(||{
|
let g = self.define_global(&sym[..], self.val_ty(sc)).unwrap_or_else(||{
|
||||||
|
@ -147,8 +148,8 @@ impl CodegenCx<'ll, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn const_str_slice(&self, s: LocalInternedString) -> &'ll Value {
|
pub fn const_str_slice(&self, s: Symbol) -> &'ll Value {
|
||||||
let len = s.len();
|
let len = s.as_str().len();
|
||||||
let cs = consts::ptrcast(self.const_cstr(s, false),
|
let cs = consts::ptrcast(self.const_cstr(s, false),
|
||||||
self.type_ptr_to(self.layout_of(self.tcx.mk_str()).llvm_type(self)));
|
self.type_ptr_to(self.layout_of(self.tcx.mk_str()).llvm_type(self)));
|
||||||
self.const_fat_ptr(cs, self.const_usize(len as u64))
|
self.const_fat_ptr(cs, self.const_usize(len as u64))
|
||||||
|
|
|
@ -29,7 +29,7 @@ use std::cell::{Cell, RefCell};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use syntax::symbol::LocalInternedString;
|
use syntax::symbol::Symbol;
|
||||||
use syntax::source_map::{DUMMY_SP, Span};
|
use syntax::source_map::{DUMMY_SP, Span};
|
||||||
use crate::abi::Abi;
|
use crate::abi::Abi;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ pub struct CodegenCx<'ll, 'tcx> {
|
||||||
pub vtables:
|
pub vtables:
|
||||||
RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
|
RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
|
||||||
/// Cache of constant strings,
|
/// Cache of constant strings,
|
||||||
pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, &'ll Value>>,
|
pub const_cstr_cache: RefCell<FxHashMap<Symbol, &'ll Value>>,
|
||||||
|
|
||||||
/// Reverse-direction for const ptrs cast from globals.
|
/// Reverse-direction for const ptrs cast from globals.
|
||||||
/// Key is a Value holding a *T,
|
/// Key is a Value holding a *T,
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::traits::*;
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use syntax::symbol::LocalInternedString;
|
use syntax::symbol::Symbol;
|
||||||
use syntax_pos::Pos;
|
use syntax_pos::Pos;
|
||||||
|
|
||||||
use super::{FunctionCx, LocalRef};
|
use super::{FunctionCx, LocalRef};
|
||||||
|
@ -397,7 +397,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
|
|
||||||
// Get the location information.
|
// Get the location information.
|
||||||
let loc = bx.sess().source_map().lookup_char_pos(span.lo());
|
let loc = bx.sess().source_map().lookup_char_pos(span.lo());
|
||||||
let filename = LocalInternedString::intern(&loc.file.name.to_string());
|
let filename = Symbol::intern(&loc.file.name.to_string());
|
||||||
let line = bx.const_u32(loc.line as u32);
|
let line = bx.const_u32(loc.line as u32);
|
||||||
let col = bx.const_u32(loc.col.to_usize() as u32 + 1);
|
let col = bx.const_u32(loc.col.to_usize() as u32 + 1);
|
||||||
|
|
||||||
|
@ -418,8 +418,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
vec![file_line_col, index, len])
|
vec![file_line_col, index, len])
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let str = msg.description();
|
let msg_str = Symbol::intern(msg.description());
|
||||||
let msg_str = LocalInternedString::intern(str);
|
|
||||||
let msg_file_line_col = bx.static_panic_msg(
|
let msg_file_line_col = bx.static_panic_msg(
|
||||||
Some(msg_str),
|
Some(msg_str),
|
||||||
filename,
|
filename,
|
||||||
|
@ -531,7 +530,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
let layout = bx.layout_of(ty);
|
let layout = bx.layout_of(ty);
|
||||||
if layout.abi.is_uninhabited() {
|
if layout.abi.is_uninhabited() {
|
||||||
let loc = bx.sess().source_map().lookup_char_pos(span.lo());
|
let loc = bx.sess().source_map().lookup_char_pos(span.lo());
|
||||||
let filename = LocalInternedString::intern(&loc.file.name.to_string());
|
let filename = Symbol::intern(&loc.file.name.to_string());
|
||||||
let line = bx.const_u32(loc.line as u32);
|
let line = bx.const_u32(loc.line as u32);
|
||||||
let col = bx.const_u32(loc.col.to_usize() as u32 + 1);
|
let col = bx.const_u32(loc.col.to_usize() as u32 + 1);
|
||||||
|
|
||||||
|
@ -539,7 +538,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
"Attempted to instantiate uninhabited type {}",
|
"Attempted to instantiate uninhabited type {}",
|
||||||
ty
|
ty
|
||||||
);
|
);
|
||||||
let msg_str = LocalInternedString::intern(&str);
|
let msg_str = Symbol::intern(&str);
|
||||||
let msg_file_line_col = bx.static_panic_msg(
|
let msg_file_line_col = bx.static_panic_msg(
|
||||||
Some(msg_str),
|
Some(msg_str),
|
||||||
filename,
|
filename,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use super::BackendTypes;
|
use super::BackendTypes;
|
||||||
use syntax_pos::symbol::LocalInternedString;
|
use syntax_pos::symbol::Symbol;
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::ty::layout::Align;
|
use rustc::ty::layout::Align;
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ pub trait StaticBuilderMethods: BackendTypes {
|
||||||
fn get_static(&mut self, def_id: DefId) -> Self::Value;
|
fn get_static(&mut self, def_id: DefId) -> Self::Value;
|
||||||
fn static_panic_msg(
|
fn static_panic_msg(
|
||||||
&mut self,
|
&mut self,
|
||||||
msg: Option<LocalInternedString>,
|
msg: Option<Symbol>,
|
||||||
filename: LocalInternedString,
|
filename: Symbol,
|
||||||
line: Self::Value,
|
line: Self::Value,
|
||||||
col: Self::Value,
|
col: Self::Value,
|
||||||
kind: &str,
|
kind: &str,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue