提交 d78b33a8 编写于 作者: N Nicholas Nethercote

Remove `LocalInternedString` uses from `librustc_codegen_llvm`.

上级 b50db34e
......@@ -5,7 +5,6 @@
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use syntax::symbol::LocalInternedString;
use rustc_codegen_ssa::common::{IntPredicate, TypeKind, RealPredicate};
use rustc_codegen_ssa::MemFlags;
use libc::{c_uint, c_char};
......@@ -24,6 +23,7 @@
use std::ops::{Deref, Range};
use std::ptr;
use std::iter::TrustedLen;
use syntax::symbol::Symbol;
// All Builders must have an llfn associated with them
#[must_use]
......@@ -1082,8 +1082,8 @@ fn get_static(&mut self, def_id: DefId) -> &'ll Value {
fn static_panic_msg(
&mut self,
msg: Option<LocalInternedString>,
filename: LocalInternedString,
msg: Option<Symbol>,
filename: Symbol,
line: Self::Value,
col: Self::Value,
kind: &str,
......
......@@ -17,7 +17,7 @@
use libc::{c_uint, c_char};
use syntax::symbol::LocalInternedString;
use syntax::symbol::Symbol;
use syntax::ast::Mutability;
pub use crate::context::CodegenCx;
......@@ -122,7 +122,7 @@ pub fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
fn const_cstr(
&self,
s: LocalInternedString,
s: Symbol,
null_terminated: bool,
) -> &'ll Value {
unsafe {
......@@ -130,9 +130,10 @@ fn const_cstr(
return llval;
}
let s_str = s.as_str();
let sc = llvm::LLVMConstStringInContext(self.llcx,
s.as_ptr() as *const c_char,
s.len() as c_uint,
s_str.as_ptr() as *const c_char,
s_str.len() as c_uint,
!null_terminated as Bool);
let sym = self.generate_local_symbol_name("str");
let g = self.define_global(&sym[..], self.val_ty(sc)).unwrap_or_else(||{
......@@ -147,8 +148,8 @@ fn const_cstr(
}
}
pub fn const_str_slice(&self, s: LocalInternedString) -> &'ll Value {
let len = s.len();
pub fn const_str_slice(&self, s: Symbol) -> &'ll Value {
let len = s.as_str().len();
let cs = consts::ptrcast(self.const_cstr(s, false),
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))
......
......@@ -29,7 +29,7 @@
use std::iter;
use std::str;
use std::sync::Arc;
use syntax::symbol::LocalInternedString;
use syntax::symbol::Symbol;
use syntax::source_map::{DUMMY_SP, Span};
use crate::abi::Abi;
......@@ -52,7 +52,7 @@ pub struct CodegenCx<'ll, 'tcx> {
pub vtables:
RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
/// 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.
/// Key is a Value holding a *T,
......
......@@ -14,7 +14,7 @@
use std::borrow::Cow;
use syntax::symbol::LocalInternedString;
use syntax::symbol::Symbol;
use syntax_pos::Pos;
use super::{FunctionCx, LocalRef};
......@@ -397,7 +397,7 @@ fn codegen_assert_terminator<'b>(
// Get the location information.
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 col = bx.const_u32(loc.col.to_usize() as u32 + 1);
......@@ -418,8 +418,7 @@ fn codegen_assert_terminator<'b>(
vec![file_line_col, index, len])
}
_ => {
let str = msg.description();
let msg_str = LocalInternedString::intern(str);
let msg_str = Symbol::intern(msg.description());
let msg_file_line_col = bx.static_panic_msg(
Some(msg_str),
filename,
......@@ -531,7 +530,7 @@ fn codegen_call_terminator<'b>(
let layout = bx.layout_of(ty);
if layout.abi.is_uninhabited() {
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 col = bx.const_u32(loc.col.to_usize() as u32 + 1);
......@@ -539,7 +538,7 @@ fn codegen_call_terminator<'b>(
"Attempted to instantiate uninhabited type {}",
ty
);
let msg_str = LocalInternedString::intern(&str);
let msg_str = Symbol::intern(&str);
let msg_file_line_col = bx.static_panic_msg(
Some(msg_str),
filename,
......
use super::BackendTypes;
use syntax_pos::symbol::LocalInternedString;
use syntax_pos::symbol::Symbol;
use rustc::hir::def_id::DefId;
use rustc::ty::layout::Align;
......@@ -12,8 +12,8 @@ pub trait StaticBuilderMethods: BackendTypes {
fn get_static(&mut self, def_id: DefId) -> Self::Value;
fn static_panic_msg(
&mut self,
msg: Option<LocalInternedString>,
filename: LocalInternedString,
msg: Option<Symbol>,
filename: Symbol,
line: Self::Value,
col: Self::Value,
kind: &str,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册