Remove SyntaxContext from {ast, hir}::{GlobalAsm, InlineAsm}
We now store it in the `Span` of the expression or item.
This commit is contained in:
parent
f70c90c677
commit
d04af194fc
10 changed files with 18 additions and 25 deletions
|
@ -984,7 +984,6 @@ impl LoweringContext<'_> {
|
||||||
volatile: asm.volatile,
|
volatile: asm.volatile,
|
||||||
alignstack: asm.alignstack,
|
alignstack: asm.alignstack,
|
||||||
dialect: asm.dialect,
|
dialect: asm.dialect,
|
||||||
ctxt: asm.ctxt,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let outputs = asm.outputs
|
let outputs = asm.outputs
|
||||||
|
|
|
@ -750,10 +750,7 @@ impl LoweringContext<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_global_asm(&mut self, ga: &GlobalAsm) -> P<hir::GlobalAsm> {
|
fn lower_global_asm(&mut self, ga: &GlobalAsm) -> P<hir::GlobalAsm> {
|
||||||
P(hir::GlobalAsm {
|
P(hir::GlobalAsm { asm: ga.asm })
|
||||||
asm: ga.asm,
|
|
||||||
ctxt: ga.ctxt,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_variant(&mut self, v: &Variant) -> hir::Variant {
|
fn lower_variant(&mut self, v: &Variant) -> hir::Variant {
|
||||||
|
|
|
@ -23,7 +23,6 @@ use rustc_target::spec::abi::Abi;
|
||||||
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
|
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
|
||||||
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
|
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
|
||||||
use syntax::attr::{InlineAttr, OptimizeAttr};
|
use syntax::attr::{InlineAttr, OptimizeAttr};
|
||||||
use syntax::ext::hygiene::SyntaxContext;
|
|
||||||
use syntax::symbol::{Symbol, kw};
|
use syntax::symbol::{Symbol, kw};
|
||||||
use syntax::tokenstream::TokenStream;
|
use syntax::tokenstream::TokenStream;
|
||||||
use syntax::util::parser::ExprPrecedence;
|
use syntax::util::parser::ExprPrecedence;
|
||||||
|
@ -2004,8 +2003,6 @@ pub struct InlineAsm {
|
||||||
pub volatile: bool,
|
pub volatile: bool,
|
||||||
pub alignstack: bool,
|
pub alignstack: bool,
|
||||||
pub dialect: AsmDialect,
|
pub dialect: AsmDialect,
|
||||||
#[stable_hasher(ignore)] // This is used for error reporting
|
|
||||||
pub ctxt: SyntaxContext,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents an argument in a function header.
|
/// Represents an argument in a function header.
|
||||||
|
@ -2184,8 +2181,6 @@ pub struct ForeignMod {
|
||||||
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||||
pub struct GlobalAsm {
|
pub struct GlobalAsm {
|
||||||
pub asm: Symbol,
|
pub asm: Symbol,
|
||||||
#[stable_hasher(ignore)] // This is used for error reporting
|
|
||||||
pub ctxt: SyntaxContext,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||||
|
|
|
@ -6,9 +6,9 @@ use crate::value::Value;
|
||||||
|
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
|
|
||||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||||
use rustc_codegen_ssa::mir::operand::OperandValue;
|
use rustc_codegen_ssa::mir::operand::OperandValue;
|
||||||
|
use syntax_pos::Span;
|
||||||
|
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use libc::{c_uint, c_char};
|
use libc::{c_uint, c_char};
|
||||||
|
@ -19,7 +19,8 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
&mut self,
|
&mut self,
|
||||||
ia: &hir::InlineAsm,
|
ia: &hir::InlineAsm,
|
||||||
outputs: Vec<PlaceRef<'tcx, &'ll Value>>,
|
outputs: Vec<PlaceRef<'tcx, &'ll Value>>,
|
||||||
mut inputs: Vec<&'ll Value>
|
mut inputs: Vec<&'ll Value>,
|
||||||
|
span: Span,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut ext_constraints = vec![];
|
let mut ext_constraints = vec![];
|
||||||
let mut output_types = vec![];
|
let mut output_types = vec![];
|
||||||
|
@ -102,7 +103,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
let kind = llvm::LLVMGetMDKindIDInContext(self.llcx,
|
let kind = llvm::LLVMGetMDKindIDInContext(self.llcx,
|
||||||
key.as_ptr() as *const c_char, key.len() as c_uint);
|
key.as_ptr() as *const c_char, key.len() as c_uint);
|
||||||
|
|
||||||
let val: &'ll Value = self.const_i32(ia.ctxt.outer_expn().as_u32() as i32);
|
let val: &'ll Value = self.const_i32(span.ctxt().outer_expn().as_u32() as i32);
|
||||||
|
|
||||||
llvm::LLVMSetMetadata(r, kind,
|
llvm::LLVMSetMetadata(r, kind,
|
||||||
llvm::LLVMMDNodeInContext(self.llcx, &val, 1));
|
llvm::LLVMMDNodeInContext(self.llcx, &val, 1));
|
||||||
|
|
|
@ -89,7 +89,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
});
|
});
|
||||||
|
|
||||||
if input_vals.len() == asm.inputs.len() {
|
if input_vals.len() == asm.inputs.len() {
|
||||||
let res = bx.codegen_inline_asm(&asm.asm, outputs, input_vals);
|
let res = bx.codegen_inline_asm(
|
||||||
|
&asm.asm,
|
||||||
|
outputs,
|
||||||
|
input_vals,
|
||||||
|
statement.source_info.span,
|
||||||
|
);
|
||||||
if !res {
|
if !res {
|
||||||
span_err!(bx.sess(), statement.source_info.span, E0668,
|
span_err!(bx.sess(), statement.source_info.span, E0668,
|
||||||
"malformed inline assembly");
|
"malformed inline assembly");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use super::BackendTypes;
|
use super::BackendTypes;
|
||||||
use crate::mir::place::PlaceRef;
|
use crate::mir::place::PlaceRef;
|
||||||
use rustc::hir::{GlobalAsm, InlineAsm};
|
use rustc::hir::{GlobalAsm, InlineAsm};
|
||||||
|
use syntax_pos::Span;
|
||||||
|
|
||||||
pub trait AsmBuilderMethods<'tcx>: BackendTypes {
|
pub trait AsmBuilderMethods<'tcx>: BackendTypes {
|
||||||
/// Take an inline assembly expression and splat it out via LLVM
|
/// Take an inline assembly expression and splat it out via LLVM
|
||||||
|
@ -9,6 +10,7 @@ pub trait AsmBuilderMethods<'tcx>: BackendTypes {
|
||||||
ia: &InlineAsm,
|
ia: &InlineAsm,
|
||||||
outputs: Vec<PlaceRef<'tcx, Self::Value>>,
|
outputs: Vec<PlaceRef<'tcx, Self::Value>>,
|
||||||
inputs: Vec<Self::Value>,
|
inputs: Vec<Self::Value>,
|
||||||
|
span: Span,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub use UnsafeSource::*;
|
||||||
pub use crate::symbol::{Ident, Symbol as Name};
|
pub use crate::symbol::{Ident, Symbol as Name};
|
||||||
pub use crate::util::parser::ExprPrecedence;
|
pub use crate::util::parser::ExprPrecedence;
|
||||||
|
|
||||||
use crate::ext::hygiene::{ExpnId, SyntaxContext};
|
use crate::ext::hygiene::ExpnId;
|
||||||
use crate::parse::token::{self, DelimToken};
|
use crate::parse::token::{self, DelimToken};
|
||||||
use crate::print::pprust;
|
use crate::print::pprust;
|
||||||
use crate::ptr::P;
|
use crate::ptr::P;
|
||||||
|
@ -1782,7 +1782,6 @@ pub struct InlineAsm {
|
||||||
pub volatile: bool,
|
pub volatile: bool,
|
||||||
pub alignstack: bool,
|
pub alignstack: bool,
|
||||||
pub dialect: AsmDialect,
|
pub dialect: AsmDialect,
|
||||||
pub ctxt: SyntaxContext,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An argument in a function header.
|
/// An argument in a function header.
|
||||||
|
@ -2030,7 +2029,6 @@ pub struct ForeignMod {
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
|
||||||
pub struct GlobalAsm {
|
pub struct GlobalAsm {
|
||||||
pub asm: Symbol,
|
pub asm: Symbol,
|
||||||
pub ctxt: SyntaxContext,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
|
|
|
@ -1182,7 +1182,7 @@ pub fn noop_visit_expr<T: MutVisitor>(Expr { node, id, span, attrs }: &mut Expr,
|
||||||
}
|
}
|
||||||
ExprKind::InlineAsm(asm) => {
|
ExprKind::InlineAsm(asm) => {
|
||||||
let InlineAsm { asm: _, asm_str_style: _, outputs, inputs, clobbers: _, volatile: _,
|
let InlineAsm { asm: _, asm_str_style: _, outputs, inputs, clobbers: _, volatile: _,
|
||||||
alignstack: _, dialect: _, ctxt: _ } = asm.deref_mut();
|
alignstack: _, dialect: _ } = asm.deref_mut();
|
||||||
for out in outputs {
|
for out in outputs {
|
||||||
let InlineAsmOutput { constraint: _, expr, is_rw: _, is_indirect: _ } = out;
|
let InlineAsmOutput { constraint: _, expr, is_rw: _, is_indirect: _ } = out;
|
||||||
vis.visit_expr(expr);
|
vis.visit_expr(expr);
|
||||||
|
|
|
@ -63,7 +63,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>,
|
||||||
MacEager::expr(P(ast::Expr {
|
MacEager::expr(P(ast::Expr {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node: ast::ExprKind::InlineAsm(P(inline_asm)),
|
node: ast::ExprKind::InlineAsm(P(inline_asm)),
|
||||||
span: sp,
|
span: sp.with_ctxt(cx.backtrace()),
|
||||||
attrs: ThinVec::new(),
|
attrs: ThinVec::new(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -277,6 +277,5 @@ fn parse_inline_asm<'a>(
|
||||||
volatile,
|
volatile,
|
||||||
alignstack,
|
alignstack,
|
||||||
dialect,
|
dialect,
|
||||||
ctxt: cx.backtrace(),
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt<'_>,
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node: ast::ItemKind::GlobalAsm(P(global_asm)),
|
node: ast::ItemKind::GlobalAsm(P(global_asm)),
|
||||||
vis: respan(sp.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
vis: respan(sp.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
||||||
span: sp,
|
span: sp.with_ctxt(cx.backtrace()),
|
||||||
tokens: None,
|
tokens: None,
|
||||||
})])
|
})])
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,5 @@ fn parse_global_asm<'a>(
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Some(ast::GlobalAsm {
|
Ok(Some(ast::GlobalAsm { asm }))
|
||||||
asm,
|
|
||||||
ctxt: cx.backtrace(),
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue